diff --git a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java index b6b4662bfb..b1f2f2ea34 100644 --- a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java +++ b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java @@ -918,33 +918,35 @@ public void downloadSdk(SdkProfileDto key, String destination) throws Exception LOG.info("Downloaded sdk to file '{}'", extractor.getDestFile()); } - public FileData downloadLogRecordLibrary(RecordKey key) throws Exception { + + public FileData downloadSdk(SdkProfileDto key) throws Exception { FileDataResponseExtractor extractor = new FileDataResponseExtractor(); RequestCallback request = new DataRequestCallback<>(key); - FileData data = restTemplate.execute(restTemplate.getUrl() + "logLibrary", + FileData data = restTemplate.execute(restTemplate.getUrl() + "sdk", HttpMethod.POST, request, extractor); return data; } - public FileData downloadLogRecordSchema(RecordKey key) throws Exception { + + public FileData downloadLogRecordLibrary(RecordKey key) throws Exception { FileDataResponseExtractor extractor = new FileDataResponseExtractor(); RequestCallback request = new DataRequestCallback<>(key); - FileData data = restTemplate.execute(restTemplate.getUrl() + "logRecordSchema", + FileData data = restTemplate.execute(restTemplate.getUrl() + "logLibrary", HttpMethod.POST, request, extractor); return data; } - public FileData downloadSdk(SdkProfileDto key) throws Exception { + public FileData downloadLogRecordSchema(RecordKey key) throws Exception { FileDataResponseExtractor extractor = new FileDataResponseExtractor(); RequestCallback request = new DataRequestCallback<>(key); - FileData data = restTemplate.execute(restTemplate.getUrl() + "sdk", + FileData data = restTemplate.execute(restTemplate.getUrl() + "logRecordSchema", HttpMethod.POST, request, extractor); return data; } public FileData downloadCtlSchemaByAppToken(CTLSchemaDto ctlSchemaDto, CTLSchemaExportMethod method, String appToken) { - FileDataResponseExtractor extractor = new FileDataResponseExtractor(); + final FileDataResponseExtractor extractor = new FileDataResponseExtractor(); MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.add("fqn", ctlSchemaDto.getMetaInfo().getFqn()); parameters.add("version", Integer.toString(ctlSchemaDto.getVersion())); diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CtlService.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CtlServiceImpl.java similarity index 99% rename from server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CtlService.java rename to server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CtlServiceImpl.java index 09542690cc..1cb2b12f4c 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CtlService.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CtlServiceImpl.java @@ -45,13 +45,14 @@ import org.kaaproject.kaa.server.common.core.configuration.RawData; import org.kaaproject.kaa.server.common.core.configuration.RawDataFactory; import org.kaaproject.kaa.server.common.core.schema.RawSchema; +import org.kaaproject.kaa.server.common.dao.CtlService; import org.kaaproject.kaa.server.common.dao.exception.DatabaseProcessingException; import org.kaaproject.kaa.server.common.dao.exception.IncorrectParameterException; -import org.kaaproject.kaa.server.common.dao.impl.CtlSchemaMetaInfoDao; import org.kaaproject.kaa.server.common.dao.impl.CtlSchemaDao; +import org.kaaproject.kaa.server.common.dao.impl.CtlSchemaMetaInfoDao; import org.kaaproject.kaa.server.common.dao.impl.DaoUtil; -import org.kaaproject.kaa.server.common.dao.model.sql.CtlSchema; import org.kaaproject.kaa.server.common.dao.model.sql.CTLSchemaMetaInfo; +import org.kaaproject.kaa.server.common.dao.model.sql.CtlSchema; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -73,13 +74,13 @@ @Service @Transactional -public class CtlService implements CtlService { +public class CtlServiceImpl implements CtlService { private static final String JSON = "application/json"; private static final String ZIP = "application/zip"; private static final String VERSION = "version"; private static final String FQN = "fqn"; - private static final Logger LOG = LoggerFactory.getLogger(CtlService.class); + private static final Logger LOG = LoggerFactory.getLogger(CtlServiceImpl.class); private static final String DEPENDENCIES = "dependencies"; private static final String DEFAULT_SYSTEM_EMPTY_SCHEMA_FILE = "/default_system_empty_schema" + ".avsc"; @@ -118,7 +119,7 @@ public CTLSchemaDto getOrCreateEmptySystemSchema(String createdUsername) { ctlSchema.setVersion(DEFAULT_SYSTEM_EMPTY_SCHEMA_VERSION); ctlSchema.setCreatedUsername(createdUsername); ctlSchema.setDependencySet(new HashSet()); - String body = getStringFromFile(DEFAULT_SYSTEM_EMPTY_SCHEMA_FILE, CtlService.class); + String body = getStringFromFile(DEFAULT_SYSTEM_EMPTY_SCHEMA_FILE, CtlServiceImpl.class); if (!body.isEmpty()) { ctlSchema.setBody(body); } else { diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/operations/pojo/RegisterProfileRequest.java b/server/node/src/main/java/org/kaaproject/kaa/server/operations/pojo/RegisterProfileRequest.java index a8c01795de..de5a39277c 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/operations/pojo/RegisterProfileRequest.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/operations/pojo/RegisterProfileRequest.java @@ -27,24 +27,15 @@ * @author ashvayka */ public class RegisterProfileRequest { - /** - * The application token. - */ + private final String appToken; - /** - * The endpoint key. - */ + private final byte[] endpointKey; - /** - * The profile. - */ + private final byte[] profile; - /** - * The sdk token. - */ private final String sdkToken; private final String accessToken; @@ -57,7 +48,8 @@ public class RegisterProfileRequest { * @param sdkToken the sdk token * @param profile the profile body */ - public RegisterProfileRequest(String appToken, byte[] endpointKey, String sdkToken, byte[] profile) { + public RegisterProfileRequest(String appToken, byte[] endpointKey, String sdkToken, + byte[] profile) { this(appToken, endpointKey, sdkToken, profile, null); } @@ -70,7 +62,8 @@ public RegisterProfileRequest(String appToken, byte[] endpointKey, String sdkTok * @param profile the profile body * @param accessToken the access token */ - public RegisterProfileRequest(String appToken, byte[] endpointKey, String sdkToken, byte[] profile, String accessToken) { + public RegisterProfileRequest(String appToken, byte[] endpointKey, String sdkToken, + byte[] profile, String accessToken) { super(); this.appToken = appToken; this.endpointKey = Arrays.copyOf(endpointKey, endpointKey.length); @@ -79,47 +72,23 @@ public RegisterProfileRequest(String appToken, byte[] endpointKey, String sdkTok this.accessToken = accessToken; } - /** - * Gets the endpoint key. - * - * @return the endpoint key - */ + public byte[] getEndpointKey() { return Arrays.copyOf(endpointKey, endpointKey.length); } - /** - * Gets the profile. - * - * @return the profile - */ public byte[] getProfile() { return Arrays.copyOf(profile, profile.length); } - /** - * Gets the application token. - * - * @return the application token - */ public String getAppToken() { return appToken; } - /** - * Gets the sdk token. - * - * @return the sdk token - */ public String getSdkToken() { return sdkToken; } - /** - * Gets the endpoint access token. - * - * @return the endpoint access token - */ public String getAccessToken() { return accessToken; } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationLogActor.java b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationLogActor.java index 6e1e1c699a..200fb12ede 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationLogActor.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationLogActor.java @@ -26,14 +26,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * The Class ApplicationLogActor - */ + public class ApplicationLogActor extends UntypedActor { - /** - * The Constant LOG. - */ + private static final Logger LOG = LoggerFactory.getLogger(ApplicationLogActor.class); private final String applicationToken; @@ -89,19 +85,12 @@ public void postStop() { LOG.info("[{}] Stoped ", applicationToken); } - /** - * The Class ActorCreator. - */ + public static class ActorCreator implements Creator { - /** - * The Constant serialVersionUID. - */ private static final long serialVersionUID = 1L; - /** - * The Akka service context - */ + private final AkkaContext context; private final String applicationToken; diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationUserVerifierActor.java b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationUserVerifierActor.java index ce1124e27c..00e4733656 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationUserVerifierActor.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/ApplicationUserVerifierActor.java @@ -25,14 +25,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * The Class ApplicationLogActor - */ + public class ApplicationUserVerifierActor extends UntypedActor { - /** - * The Constant LOG. - */ private static final Logger LOG = LoggerFactory.getLogger(ApplicationUserVerifierActor.class); private final String applicationId; @@ -46,8 +41,12 @@ public class ApplicationUserVerifierActor extends UntypedActor { * @param applicationToken the application token */ private ApplicationUserVerifierActor(AkkaContext context, String applicationToken) { - this.applicationId = context.getApplicationService().findAppByApplicationToken(applicationToken).getId(); - this.messageProcessor = new ApplicationUserVerifierActorMessageProcessor(context.getEndpointUserService(), applicationId); + this.applicationId = context.getApplicationService() + .findAppByApplicationToken(applicationToken) + .getId(); + this.messageProcessor = new ApplicationUserVerifierActorMessageProcessor( + context.getEndpointUserService(), applicationId + ); } /* @@ -88,19 +87,11 @@ public void postStop() { LOG.info("[{}] Stoped ", applicationId); } - /** - * The Class ActorCreator. - */ public static class ActorCreator implements Creator { - /** - * The Constant serialVersionUID. - */ private static final long serialVersionUID = 1L; - /** - * The Akka service context - */ + private final AkkaContext context; private final String applicationToken; diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/TenantActor.java b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/TenantActor.java index cdeba0f9bc..32780e5e89 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/TenantActor.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/TenantActor.java @@ -59,29 +59,20 @@ public class TenantActor extends UntypedActor { - /** - * The Constant LOG. - */ + private static final Logger LOG = LoggerFactory.getLogger(TenantActor.class); /** - * The Akka service context + * The Akka service context. */ private final AkkaContext context; - /** - * The applications. - */ + private final Map applications; - /** - * The local users. - */ private final Map localUsers; - /** - * The global users. - */ + private final Map globalUsers; private final String tenantId; @@ -95,7 +86,7 @@ private TenantActor(AkkaContext context, String tenantId) { this.applications = new HashMap<>(); this.localUsers = new HashMap<>(); this.globalUsers = new HashMap<>(); - this.statusRequestStatesMap = new HashMap(); + this.statusRequestStatesMap = new HashMap<>(); } @Override @@ -163,7 +154,8 @@ private void processClusterUpdate(ClusterUpdateMessage message) { private void processStatusRequest(StatusRequestMessage message) { LOG.debug("[{}] Processing status request", message.getId()); - statusRequestStatesMap.put(message.getId(), new StatusRequestState(message, applications.size())); + statusRequestStatesMap.put(message.getId(), + new StatusRequestState(message, applications.size())); for (ActorRef tenant : applications.values()) { tenant.tell(new StatusRequestMessage(message.getId()), this.getSelf()); } @@ -174,7 +166,9 @@ private void processStatusResponse(ApplicationActorStatusResponse message) { if (state != null) { if (state.processResponse(message)) { int endpointCount = state.getEndpontCount(); - context().parent().tell(new TenantActorStatusResponse(message.getRequestId(), endpointCount), ActorRef.noSender()); + context().parent().tell( + new TenantActorStatusResponse(message.getRequestId(), endpointCount), + ActorRef.noSender()); } } else { LOG.warn("[{}] State for status request is not found", message.getRequestId()); @@ -182,7 +176,8 @@ private void processStatusResponse(ApplicationActorStatusResponse message) { } private void processSessionControlMessage(SessionControlMessage message) { - ActorRef applicationActor = getOrCreateApplicationActor(message.getSessionInfo().getApplicationToken()); + ActorRef applicationActor = getOrCreateApplicationActor( + message.getSessionInfo().getApplicationToken()); applicationActor.tell(message, self()); } @@ -239,7 +234,8 @@ private void processUserAwareMessage(UserAwareMessage message) { if (userActor != null) { userActor.tell(message, self()); } else { - LOG.debug("[{}] user aware message ignored due to no such user actor: [{}]", tenantId, message.getUserId()); + LOG.debug("[{}] user aware message ignored due to no such user actor: [{}]", + tenantId, message.getUserId()); } } @@ -252,7 +248,8 @@ private ActorRef getOrCreateUserActor(String userId) { ActorRef userActor = localUsers.get(localUserId); if (userActor == null && userId != null) { userActor = context().actorOf( - Props.create(new LocalUserActor.ActorCreator(context, userId, tenantId)).withDispatcher(USER_DISPATCHER_NAME), + Props.create(new LocalUserActor.ActorCreator(context, userId, tenantId)) + .withDispatcher(USER_DISPATCHER_NAME), localUserId); LOG.debug("Create local user actor with id {}", userId); localUsers.put(localUserId, userActor); @@ -266,7 +263,8 @@ private ActorRef getOrCreateGlobalUserActor(String userId) { ActorRef userActor = globalUsers.get(globalUserId); if (userActor == null && userId != null) { userActor = context().actorOf( - Props.create(new GlobalUserActor.ActorCreator(context, userId, tenantId)).withDispatcher(USER_DISPATCHER_NAME), + Props.create(new GlobalUserActor.ActorCreator(context, userId, tenantId)) + .withDispatcher(USER_DISPATCHER_NAME), globalUserId); LOG.debug("Create global user actor with id {}", userId); globalUsers.put(globalUserId, userActor); @@ -285,7 +283,9 @@ private ActorRef getOrCreateApplicationActor(String appToken) { ActorRef applicationActor = applications.get(appToken); if (applicationActor == null) { applicationActor = context().actorOf( - Props.create(new ApplicationActor.ActorCreator(context, tenantId, appToken)).withDispatcher(CORE_DISPATCHER_NAME), appToken); + Props.create(new ApplicationActor.ActorCreator(context, tenantId, appToken)) + .withDispatcher(CORE_DISPATCHER_NAME), + appToken); applications.put(appToken, applicationActor); } return applicationActor; @@ -341,19 +341,12 @@ public void postStop() { LOG.info("[{}] Stoped", tenantId); } - /** - * The Class ActorCreator. - */ + public static class ActorCreator implements Creator { - /** - * The Constant serialVersionUID. - */ private static final long serialVersionUID = 1L; - /** - * The Akka service context - */ + private final AkkaContext context; private final String tenantId; diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/endpoint/local/LocalEndpointActor.java b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/endpoint/local/LocalEndpointActor.java index f61756b645..18a1a47061 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/endpoint/local/LocalEndpointActor.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/endpoint/local/LocalEndpointActor.java @@ -39,14 +39,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * The Class EndpointActor. - */ public class LocalEndpointActor extends UntypedActor { - /** - * The Constant LOG. - */ private static final Logger LOG = LoggerFactory.getLogger(LocalEndpointActor.class); private final String actorKey; @@ -61,8 +55,10 @@ public class LocalEndpointActor extends UntypedActor { * @param appToken the app token * @param key the key */ - LocalEndpointActor(AkkaContext context, String endpointActorKey, String appToken, EndpointObjectHash key) { - this.messageProcessor = new LocalEndpointActorMessageProcessor(context, appToken, key, endpointActorKey); + LocalEndpointActor(AkkaContext context, String endpointActorKey, + String appToken, EndpointObjectHash key) { + this.messageProcessor = new LocalEndpointActorMessageProcessor(context, + appToken, key, endpointActorKey); this.actorKey = endpointActorKey; } @@ -118,7 +114,8 @@ private void processEndpointActorMsg(EndpointActorMsg msg) { messageProcessor.processEndpointActorMsg(context(), msg); } - private void processUserConfigurationUpdateMessage(EndpointUserConfigurationUpdateMessage message) { + private void processUserConfigurationUpdateMessage( + EndpointUserConfigurationUpdateMessage message) { messageProcessor.processUserConfigurationUpdate(context(), message); } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/user/GlobalUserActorMessageProcessor.java b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/user/GlobalUserActorMessageProcessor.java index 325d18daee..e9a3d45465 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/user/GlobalUserActorMessageProcessor.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/operations/service/akka/actors/core/user/GlobalUserActorMessageProcessor.java @@ -40,9 +40,7 @@ public class GlobalUserActorMessageProcessor { private static final Logger LOG = LoggerFactory.getLogger(GlobalUserActor.class); - /** - * The event service. - */ + private final EventService eventService; private final String userId; private final String tenantId; @@ -59,15 +57,18 @@ public GlobalUserActorMessageProcessor(AkkaContext context, String userId, Strin public void process(ActorContext context, GlobalRouteInfo route) { if (route.getRouteOperation() == RouteOperation.ADD) { - LOG.debug("[{}][{}] Adding route {} for cf version {}", tenantId, userId, route, route.getCfVersion()); + LOG.debug("[{}][{}] Adding route {} for cf version {}", + tenantId, userId, route, route.getCfVersion()); ConfigurationKey key = ConfigurationKey.fromRouteInfo(route); map.add(key, route); checkHashAndSendNotification(context, key, route); } else if (route.getRouteOperation() == RouteOperation.DELETE) { - LOG.debug("[{}][{}] Remove route {} for cf version {}", tenantId, userId, route, route.getCfVersion()); + LOG.debug("[{}][{}] Remove route {} for cf version {}", + tenantId, userId, route, route.getCfVersion()); map.remove(route); } else { - LOG.warn("[{}][{}] unsupported route operations {}", tenantId, userId, route.getRouteOperation()); + LOG.warn("[{}][{}] unsupported route operations {}", + tenantId, userId, route.getRouteOperation()); } } @@ -79,13 +80,17 @@ public void process(ActorContext context, UserConfigurationUpdate update) { sendStateUpdatesToRemoteServers(context, key, update); } - private void sendStateUpdatesToLocalServers(ActorContext context, ConfigurationKey key, UserConfigurationUpdate update) { + private void sendStateUpdatesToLocalServers(ActorContext context, + ConfigurationKey key, + UserConfigurationUpdate update) { for (GlobalRouteInfo route : map.getLocalRoutes(key)) { checkHashAndSendNotification(context, update.getHash(), route); } } - private void sendStateUpdatesToRemoteServers(ActorContext context, ConfigurationKey key, UserConfigurationUpdate update) { + private void sendStateUpdatesToRemoteServers(ActorContext context, + ConfigurationKey key, + UserConfigurationUpdate update) { Map> routes = map.getRemoteRoutes(key); for (Entry> entry : routes.entrySet()) { LOG.debug("Sending notification to {} about configuration update", entry.getKey()); @@ -95,7 +100,9 @@ private void sendStateUpdatesToRemoteServers(ActorContext context, Configuration } } - private void checkHashAndSendNotification(ActorContext context, ConfigurationKey key, GlobalRouteInfo route) { + private void checkHashAndSendNotification(ActorContext context, + ConfigurationKey key, + GlobalRouteInfo route) { byte[] currentUcfHash = ucfHashes.get(key); if (currentUcfHash != null) { checkHashAndSendNotification(context, currentUcfHash, route); @@ -104,13 +111,18 @@ private void checkHashAndSendNotification(ActorContext context, ConfigurationKey } } - private void checkHashAndSendNotification(ActorContext context, byte[] newHash, GlobalRouteInfo route) { + private void checkHashAndSendNotification(ActorContext context, byte[] newHash, + GlobalRouteInfo route) { if (!Arrays.equals(newHash, route.getUcfHash())) { LOG.trace("Sending notification to route {}", route); if (route.isLocal()) { - context.parent().tell(new EndpointUserConfigurationUpdateMessage(toUpdate(newHash, route)), context.self()); + context.parent() + .tell( + new EndpointUserConfigurationUpdateMessage(toUpdate(newHash, route)), + context.self()); } else { - eventService.sendEndpointStateInfo(route.getAddress().getServerId(), toUpdate(newHash, route)); + eventService + .sendEndpointStateInfo(route.getAddress().getServerId(), toUpdate(newHash, route)); } } else { LOG.trace("Ignoring notification to route {} due to matching hashes", route); @@ -118,8 +130,9 @@ private void checkHashAndSendNotification(ActorContext context, byte[] newHash, } private EndpointUserConfigurationUpdate toUpdate(byte[] newHash, GlobalRouteInfo route) { - return new EndpointUserConfigurationUpdate(tenantId, userId, route.getAddress().getApplicationToken(), route.getAddress() - .getEndpointKey(), newHash); + return new EndpointUserConfigurationUpdate( + tenantId, userId, route.getAddress().getApplicationToken(), + route.getAddress().getEndpointKey(), newHash); } public void processClusterUpdate(ActorContext context) { @@ -232,7 +245,7 @@ public Set getRoutes(T key) { } public Set getLocalRoutes(T key) { - Set result = new HashSet(); + Set result = new HashSet<>(); for (GlobalRouteInfo route : getRoutes(key)) { if (route.getAddress().getServerId() != null) { continue; @@ -243,7 +256,7 @@ public Set getLocalRoutes(T key) { } public Map> getRemoteRoutes(T key) { - Map> result = new HashMap>(); + Map> result = new HashMap<>(); for (GlobalRouteInfo route : getRoutes(key)) { String serverId = route.getAddress().getServerId(); if (serverId == null) { @@ -251,7 +264,7 @@ public Map> getRemoteRoutes(T key) { } Set set = result.get(serverId); if (set == null) { - set = new HashSet(); + set = new HashSet<>(); result.put(serverId, set); } set.add(route); diff --git a/server/node/src/main/java/org/spring4gwt/server/SpringGwtRemoteServiceServlet.java b/server/node/src/main/java/org/spring4gwt/server/SpringGwtRemoteServiceServlet.java index bb89051207..5eb71138bd 100644 --- a/server/node/src/main/java/org/spring4gwt/server/SpringGwtRemoteServiceServlet.java +++ b/server/node/src/main/java/org/spring4gwt/server/SpringGwtRemoteServiceServlet.java @@ -33,13 +33,10 @@ @SuppressWarnings("serial") public class SpringGwtRemoteServiceServlet extends RemoteServiceServlet { - /** - * The Constant LOG. - */ + private static final Logger LOG = LoggerFactory.getLogger(SpringGwtRemoteServiceServlet.class); - static ThreadLocal perThreadRequest = - new ThreadLocal(); + static ThreadLocal perThreadRequest = new ThreadLocal<>(); public static HttpServletRequest getRequest() { return perThreadRequest.get(); @@ -64,10 +61,16 @@ public String processCall(String payload) throws SerializationException { RPCRequest rpcRequest = RPC.decodeRequest(payload, handler.getClass(), this); onAfterRequestDeserialized(rpcRequest); if (LOG.isDebugEnabled()) { - LOG.debug("Invoking " + handler.getClass().getName() + "." + rpcRequest.getMethod().getName()); + LOG.debug("Invoking " + handler.getClass().getName() + + "." + rpcRequest.getMethod().getName()); } - return RpcHelper.invokeAndEncodeResponse(handler, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest - .getSerializationPolicy()); + return RpcHelper + .invokeAndEncodeResponse( + handler, + rpcRequest.getMethod(), + rpcRequest.getParameters(), + rpcRequest.getSerializationPolicy() + ); } catch (IncompatibleRemoteServiceException ex) { log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex); return RPC.encodeResponseForFailure(null, ex); @@ -91,7 +94,8 @@ protected Object getBean(HttpServletRequest request) { String service = getService(request); Object bean = getBean(service); if (!(bean instanceof RemoteService)) { - throw new IllegalArgumentException("Spring bean is not a GWT RemoteService: " + service + " (" + bean + ")"); + throw new IllegalArgumentException("Spring bean is not a GWT RemoteService: " + + service + " (" + bean + ")"); } if (LOG.isDebugEnabled()) { LOG.debug("Bean for service " + service + " is " + bean); @@ -99,20 +103,6 @@ protected Object getBean(HttpServletRequest request) { return bean; } - /** - * Parse the service name from the request URL. - * - * @param request the request - * @return bean name - */ - protected String getService(HttpServletRequest request) { - String url = request.getRequestURI(); - String service = url.substring(url.lastIndexOf("/") + 1); - if (LOG.isDebugEnabled()) { - LOG.debug("Service for URL {} is {}", url, service); - } - return service; - } /** * Look up a spring bean with the specified name in the current web @@ -134,4 +124,21 @@ protected Object getBean(String name) { } return applicationContext.getBean(name); } + + /** + * Parse the service name from the request URL. + * + * @param request the request + * @return bean name + */ + protected String getService(HttpServletRequest request) { + String url = request.getRequestURI(); + String service = url.substring(url.lastIndexOf("/") + 1); + if (LOG.isDebugEnabled()) { + LOG.debug("Service for URL {} is {}", url, service); + } + return service; + } + + }