Skip to content

Commit

Permalink
checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonArp committed Jan 9, 2017
1 parent c767e82 commit 1dd9350
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/arpnetworking/akka/ActorBuilder.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2016 InscopeMetrics, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arpnetworking.akka;

import akka.actor.Props;
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/arpnetworking/akka/NonJoiningClusterJoiner.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016 Inscope Metrics
* Copyright 2016 Inscope Metrics, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,9 +60,17 @@ public void onReceive(final Object message) throws Exception {
unhandled(message);
}

private static Logger LOGGER = LoggerFactory.getLogger(NonJoiningClusterJoiner.class);
private static final Logger LOGGER = LoggerFactory.getLogger(NonJoiningClusterJoiner.class);

/**
* Implementation of the {@link com.arpnetworking.commons.builder.Builder} pattern for a {@link NonJoiningClusterJoiner}.
*
* @author Brandon Arp (brandon dot arp at inscopemetrics dot com)
*/
public static class Builder extends ActorBuilder<Builder> {
/**
* Public constructor.
*/
public Builder() {
super(NonJoiningClusterJoiner::props);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/**
* Copyright 2016 InscopeMetrics, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arpnetworking.configuration.jackson.akka;

import akka.actor.Props;
import com.arpnetworking.commons.builder.Builder;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand All @@ -14,7 +28,8 @@
import java.io.IOException;

/**
* Deserializer that will create an ActorBuilder for the given actor, then create the Actor from Guice
* Deserializer that will create an ActorBuilder for the given actor, then create a Props from Guice.
*
* @author Brandon Arp (brandon dot arp at inscopemetrics dot com)
*/
public class ActorBuilderDeserializer extends JsonDeserializer<Props> {
Expand All @@ -28,15 +43,15 @@ public ActorBuilderDeserializer(final ObjectMapper mapper) {
}

@Override
public Props deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
public Props deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
final TreeNode treeNode = p.readValueAsTree();
final String type = ((TextNode) treeNode.get("type")).textValue();
try {
final Class<?> clazz = Class.forName(type);
final Class<? extends Builder<? extends Props>> builder = getBuilderForClass(clazz);
final Builder<? extends Props> value = _mapper.readValue(treeNode.toString(), builder);
return value.build();
} catch (ClassNotFoundException e) {
} catch (final ClassNotFoundException e) {
throw new JsonMappingException(p, String.format("Unable to find class %s referenced by Props type", type));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2016 InscopeMetrics, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arpnetworking.clusteraggregator.configuration;

import akka.actor.Props;
Expand Down Expand Up @@ -29,9 +44,9 @@ public void testPolyDeserialize() throws IOException {
module.addDeserializer(Props.class, new ActorBuilderDeserializer(mapper));
mapper.registerModule(module);

@Language("JSON") final String data = "{\n" +
" \"type\": \"com.arpnetworking.akka.NonJoiningClusterJoiner\"\n" +
"}";
@Language("JSON") final String data = "{\n"
+ " \"type\": \"com.arpnetworking.akka.NonJoiningClusterJoiner\"\n"
+ "}";
final Props props = mapper.readValue(data, Props.class);
}
}

0 comments on commit 1dd9350

Please sign in to comment.