repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
Epic-Breakfast-Productions/OWAT | implementations/java/OWAT-lib/src/test/java/com/ebp/owat/lib/runner/RunnerTest.java | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
| import com.ebp.owat.lib.datastructure.value.NodeMode;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals; | package com.ebp.owat.lib.runner;
@RunWith(Parameterized.class)
public class RunnerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(RunnerTest.class);
private final String data;
public RunnerTest(String data){
this.data = data;
}
private static ScrambleRunner.Builder getBuilder(){
ScrambleRunner.Builder builder = new ScrambleRunner.Builder();
return builder;
}
| // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
// Path: implementations/java/OWAT-lib/src/test/java/com/ebp/owat/lib/runner/RunnerTest.java
import com.ebp.owat.lib.datastructure.value.NodeMode;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
package com.ebp.owat.lib.runner;
@RunWith(Parameterized.class)
public class RunnerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(RunnerTest.class);
private final String data;
public RunnerTest(String data){
this.data = data;
}
private static ScrambleRunner.Builder getBuilder(){
ScrambleRunner.Builder builder = new ScrambleRunner.Builder();
return builder;
}
| private void runTest(NodeMode mode) throws IOException { |
Epic-Breakfast-Productions/OWAT | implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/ScrambleResults.java | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
| import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.SCRAMBLING; | package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the results from scrambling.
*/
public class ScrambleResults extends RunResults {
/**
* Base constructor.
*/
public ScrambleResults(){
super(SCRAMBLING);
}
/**
* Constructor to set the node mode used.
* @param nodeMode The node mode used.
*/ | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/ScrambleResults.java
import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.SCRAMBLING;
package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the results from scrambling.
*/
public class ScrambleResults extends RunResults {
/**
* Base constructor.
*/
public ScrambleResults(){
super(SCRAMBLING);
}
/**
* Constructor to set the node mode used.
* @param nodeMode The node mode used.
*/ | public ScrambleResults(NodeMode nodeMode){ |
Epic-Breakfast-Productions/OWAT | implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/ScrambleResults.java | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
| import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.SCRAMBLING; | package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the results from scrambling.
*/
public class ScrambleResults extends RunResults {
/**
* Base constructor.
*/
public ScrambleResults(){
super(SCRAMBLING);
}
/**
* Constructor to set the node mode used.
* @param nodeMode The node mode used.
*/
public ScrambleResults(NodeMode nodeMode){
super(SCRAMBLING, nodeMode);
}
@Override
public synchronized ScrambleResults clone(){
ScrambleResults output = new ScrambleResults(this.getNodeMode());
output.setMatrixMode(this.getMatrixMode());
output.setCurStep(this.getCurStep());
output.setCurStepProgMax(this.getCurStepProgMax());
output.setCurStepProg(this.getCurStepProg());
output.setTimingMap(this.getTimingMap());
output.setMatrixSize(this.getMatrixSize());
output.setNumBytesIn(this.getNumBytesIn());
output.setNumBytesOut(this.getNumBytesOut());
return output;
}
/**
* Gets the CSV head used for scrambling data results.
* @return The CSV head used for scrambling data results.
*/
public static String getCsvHead(){
StringBuilder sb = new StringBuilder(RunResults.getCsvHeadBase());
| // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/ScrambleResults.java
import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.SCRAMBLING;
package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the results from scrambling.
*/
public class ScrambleResults extends RunResults {
/**
* Base constructor.
*/
public ScrambleResults(){
super(SCRAMBLING);
}
/**
* Constructor to set the node mode used.
* @param nodeMode The node mode used.
*/
public ScrambleResults(NodeMode nodeMode){
super(SCRAMBLING, nodeMode);
}
@Override
public synchronized ScrambleResults clone(){
ScrambleResults output = new ScrambleResults(this.getNodeMode());
output.setMatrixMode(this.getMatrixMode());
output.setCurStep(this.getCurStep());
output.setCurStepProgMax(this.getCurStepProgMax());
output.setCurStepProg(this.getCurStepProg());
output.setTimingMap(this.getTimingMap());
output.setMatrixSize(this.getMatrixSize());
output.setNumBytesIn(this.getNumBytesIn());
output.setNumBytesOut(this.getNumBytesOut());
return output;
}
/**
* Gets the CSV head used for scrambling data results.
* @return The CSV head used for scrambling data results.
*/
public static String getCsvHead(){
StringBuilder sb = new StringBuilder(RunResults.getCsvHeadBase());
| for (Step curStep : Step.getStepsIn(SCRAMBLING)) { |
Epic-Breakfast-Productions/OWAT | implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/DescrambleResults.java | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
| import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.DESCRAMBLING; | package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the run results from descrambling.
*/
public class DescrambleResults extends RunResults {
/**
* Base constructor.
*/
public DescrambleResults(){
super(DESCRAMBLING);
}
/**
* Constructor to setup the node mode.
* @param nodeMode The node mode used.
*/ | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/DescrambleResults.java
import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.DESCRAMBLING;
package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the run results from descrambling.
*/
public class DescrambleResults extends RunResults {
/**
* Base constructor.
*/
public DescrambleResults(){
super(DESCRAMBLING);
}
/**
* Constructor to setup the node mode.
* @param nodeMode The node mode used.
*/ | public DescrambleResults(NodeMode nodeMode){ |
Epic-Breakfast-Productions/OWAT | implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/DescrambleResults.java | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
| import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.DESCRAMBLING; | package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the run results from descrambling.
*/
public class DescrambleResults extends RunResults {
/**
* Base constructor.
*/
public DescrambleResults(){
super(DESCRAMBLING);
}
/**
* Constructor to setup the node mode.
* @param nodeMode The node mode used.
*/
public DescrambleResults(NodeMode nodeMode){
super(DESCRAMBLING, nodeMode);
}
@Override
public synchronized DescrambleResults clone(){
DescrambleResults output = new DescrambleResults(this.getNodeMode());
output.setMatrixMode(this.getMatrixMode());
output.setCurStep(this.getCurStep());
output.setCurStepProgMax(this.getCurStepProgMax());
output.setCurStepProg(this.getCurStepProg());
output.setTimingMap(this.getTimingMap());
output.setMatrixSize(this.getMatrixSize());
output.setNumBytesIn(this.getNumBytesIn());
output.setNumBytesOut(this.getNumBytesOut());
return output;
}
/**
* Gets the CSV head used for descrambling data results.
* @return The CSV head used for descrambling data results.
*/
public static String getCsvHead(){
StringBuilder sb = new StringBuilder(RunResults.getCsvHeadBase());
| // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/NodeMode.java
// public enum NodeMode {
// BIT(SerializationConstants.BIT_TYPE_STR, BitValue.class),BYTE(SerializationConstants.BYTE_TYPE_STR, ByteValue.class);
//
// public final String typeStr;
// public final Class<? extends Value> typeClass;
//
// NodeMode(String typeStr, Class<? extends Value> typeClass){
// this.typeStr = typeStr;
// this.typeClass = typeClass;
// }
// }
//
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/Step.java
// public enum Step {
// NOT_STARTED_SCRAMBLE(0, "Not Started", ScrambleMode.SCRAMBLING),
// NOT_STARTED_DESCRAMBLE(0, "Not Started", ScrambleMode.DESCRAMBLING),
//
// LOAD_DATA(1, "Loading Data", ScrambleMode.SCRAMBLING),
// PAD_DATA(2, "Padding Data", ScrambleMode.SCRAMBLING),
// SCRAMBLING(3, "Scrambling", ScrambleMode.SCRAMBLING),
// OUT_SCRAMBLED_DATA(4, "Outputting Scrambled Data", ScrambleMode.SCRAMBLING),
// OUT_KEY(5, "Outputting key", ScrambleMode.SCRAMBLING),
// DONE_SCRAMBLING(6, "Done", ScrambleMode.SCRAMBLING),
//
// LOAD_KEY(1, "Loading Key", ScrambleMode.DESCRAMBLING),
// LOAD_SCRAMBLED_DATA(2, "Loading Scrambled Data", ScrambleMode.DESCRAMBLING),
// DESCRAMBLING(3, "Descrambling", ScrambleMode.DESCRAMBLING),
// OUT_DESCRAMBLED_DATA(4, "Outputting Descrambled Data", ScrambleMode.DESCRAMBLING),
// DONE_DESCRAMBLING(5, "Done", ScrambleMode.DESCRAMBLING);
//
// /** The step number of the step. */
// public final int stepNo;
// /** The name of the step. */
// public final String stepName;
// /** The mode the step is part of. */
// public final ScrambleMode mode;
//
// Step(int stepNo, String name, ScrambleMode mode){
// this.stepNo = stepNo;
// this.stepName = name;
// this.mode = mode;
// }
//
// /**
// * Gets the steps that are part of a mode.
// * @param mode The mode to get the steps of
// * @return The list of steps in the mode.
// */
// public static List<Step> getStepsIn(ScrambleMode mode){
// List<Step> steps = new LinkedList<>();
//
// for(Step curStep : Step.values()){
// if(
// curStep == NOT_STARTED_SCRAMBLE ||
// curStep == NOT_STARTED_DESCRAMBLE ||
// curStep == DONE_DESCRAMBLING ||
// curStep == DONE_SCRAMBLING
// ){
// continue;
// }
// if(curStep.mode == mode){
// steps.add(curStep);
// }
// }
// return steps;
// }
// }
// Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/runner/utils/results/DescrambleResults.java
import com.ebp.owat.lib.datastructure.value.NodeMode;
import com.ebp.owat.lib.runner.utils.Step;
import static com.ebp.owat.lib.runner.utils.ScrambleMode.DESCRAMBLING;
package com.ebp.owat.lib.runner.utils.results;
/**
* Represents the run results from descrambling.
*/
public class DescrambleResults extends RunResults {
/**
* Base constructor.
*/
public DescrambleResults(){
super(DESCRAMBLING);
}
/**
* Constructor to setup the node mode.
* @param nodeMode The node mode used.
*/
public DescrambleResults(NodeMode nodeMode){
super(DESCRAMBLING, nodeMode);
}
@Override
public synchronized DescrambleResults clone(){
DescrambleResults output = new DescrambleResults(this.getNodeMode());
output.setMatrixMode(this.getMatrixMode());
output.setCurStep(this.getCurStep());
output.setCurStepProgMax(this.getCurStepProgMax());
output.setCurStepProg(this.getCurStepProg());
output.setTimingMap(this.getTimingMap());
output.setMatrixSize(this.getMatrixSize());
output.setNumBytesIn(this.getNumBytesIn());
output.setNumBytesOut(this.getNumBytesOut());
return output;
}
/**
* Gets the CSV head used for descrambling data results.
* @return The CSV head used for descrambling data results.
*/
public static String getCsvHead(){
StringBuilder sb = new StringBuilder(RunResults.getCsvHeadBase());
| for (Step curStep : Step.getStepsIn(DESCRAMBLING)) { |
Epic-Breakfast-Productions/OWAT | implementations/java/OWAT-lib/src/test/java/com/ebp/owat/lib/structure/value/ValueFlagTest.java | // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/ValueFlag.java
// public enum ValueFlag {
// /** Flag for determining if the value is part of the original data or not. */
// IS_ORIGINAL((byte)1),
// /** For the {@link BitValue} Node. Holds the value of that value. */
// VALUE((byte)128);
//
// /**
// * The offset of the flag, for bitwise operations to get/set the flag.
// */
// public final byte offset;
//
// /**
// * Constructor to setup the flag.
// * @param offset The offset of the flag.
// */
// ValueFlag(byte offset){
// this.offset = offset;
// }
//
// /**
// * Gets the flag value set in the byte.
// * @param data The byte to get the flag out of.
// * @return The value of the flag set in the byte.
// */
// public boolean getFlag(byte data){
// return (this.offset & data) == this.offset;
// }
//
// /**
// * Sets this flag in the byte.
// * @param data The data to set the data in.
// * @return The byte with this flag set.
// */
// public byte setFlag(byte data){
// return (byte)(this.offset | data);
// }
// }
| import com.ebp.owat.lib.datastructure.value.ValueFlag;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; | package com.ebp.owat.lib.structure.value;
@RunWith(Parameterized.class)
public class ValueFlagTest {
| // Path: implementations/java/OWAT-lib/src/main/java/com/ebp/owat/lib/datastructure/value/ValueFlag.java
// public enum ValueFlag {
// /** Flag for determining if the value is part of the original data or not. */
// IS_ORIGINAL((byte)1),
// /** For the {@link BitValue} Node. Holds the value of that value. */
// VALUE((byte)128);
//
// /**
// * The offset of the flag, for bitwise operations to get/set the flag.
// */
// public final byte offset;
//
// /**
// * Constructor to setup the flag.
// * @param offset The offset of the flag.
// */
// ValueFlag(byte offset){
// this.offset = offset;
// }
//
// /**
// * Gets the flag value set in the byte.
// * @param data The byte to get the flag out of.
// * @return The value of the flag set in the byte.
// */
// public boolean getFlag(byte data){
// return (this.offset & data) == this.offset;
// }
//
// /**
// * Sets this flag in the byte.
// * @param data The data to set the data in.
// * @return The byte with this flag set.
// */
// public byte setFlag(byte data){
// return (byte)(this.offset | data);
// }
// }
// Path: implementations/java/OWAT-lib/src/test/java/com/ebp/owat/lib/structure/value/ValueFlagTest.java
import com.ebp.owat.lib.datastructure.value.ValueFlag;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
package com.ebp.owat.lib.structure.value;
@RunWith(Parameterized.class)
public class ValueFlagTest {
| private final ValueFlag flag; |
TGAC/RAMPART | src/main/java/uk/ac/tgac/jellyswarm/JellyswarmCLI.java | // Path: src/main/java/uk/ac/tgac/rampart/util/CommandLineHelper.java
// public class CommandLineHelper {
//
// public static void printHelp(OutputStream outputStream, String title, String description, Options options) {
// final PrintWriter writer = new PrintWriter(outputStream);
// final HelpFormatter helpFormatter = new HelpFormatter();
// helpFormatter.printHelp(
// writer,
// 100,
// title,
// description,
// options,
// 3,
// 3,
// "Created by The Genome Analysis Centre (TGAC), Norwich, UK\n" +
// "Contact: [email protected]",
// true);
// writer.flush();
// }
// }
| import org.apache.commons.cli.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.ebi.fgpt.conan.core.user.GuestUser;
import uk.ac.ebi.fgpt.conan.model.ConanPipeline;
import uk.ac.ebi.fgpt.conan.model.ConanTask;
import uk.ac.ebi.fgpt.conan.model.context.ExecutionContext;
import uk.ac.ebi.fgpt.conan.model.param.ParamMap;
import uk.ac.ebi.fgpt.conan.properties.ConanProperties;
import uk.ac.ebi.fgpt.conan.service.DefaultExecutorService;
import uk.ac.ebi.fgpt.conan.service.DefaultProcessService;
import uk.ac.ebi.fgpt.conan.service.exception.TaskExecutionException;
import uk.ac.ebi.fgpt.conan.util.AbstractConanCLI;
import uk.ac.tgac.conan.core.util.JarUtils;
import uk.ac.tgac.rampart.util.CommandLineHelper;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; |
this.memory = commandLine.hasOption(OPT_MEMORY) ?
Integer.parseInt(commandLine.getOptionValue(OPT_MEMORY)) :
DEFAULT_MEMORY;
this.recursive = commandLine.hasOption(OPT_RECURSIVE);
this.single = commandLine.hasOption(OPT_SINGLE);
// Check for a single arg left on the command line
if (commandLine.getArgs().length != 1)
throw new ParseException("Unexpected number of arguments on the command line. Expected 1, found " +
commandLine.getArgs().length);
// This is the input directory containing libraries to analyse.
this.inputDir = new File(commandLine.getArgs()[0]);
}
@Override
protected ParamMap createArgMap() {
return this.args.getArgMap();
}
@Override
protected ConanPipeline createPipeline() throws IOException {
return new Jellyswarm.Pipeline(this.args, new DefaultExecutorService(new DefaultProcessService(), this.executionContext));
}
@Override
protected void printHelp() { | // Path: src/main/java/uk/ac/tgac/rampart/util/CommandLineHelper.java
// public class CommandLineHelper {
//
// public static void printHelp(OutputStream outputStream, String title, String description, Options options) {
// final PrintWriter writer = new PrintWriter(outputStream);
// final HelpFormatter helpFormatter = new HelpFormatter();
// helpFormatter.printHelp(
// writer,
// 100,
// title,
// description,
// options,
// 3,
// 3,
// "Created by The Genome Analysis Centre (TGAC), Norwich, UK\n" +
// "Contact: [email protected]",
// true);
// writer.flush();
// }
// }
// Path: src/main/java/uk/ac/tgac/jellyswarm/JellyswarmCLI.java
import org.apache.commons.cli.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.ebi.fgpt.conan.core.user.GuestUser;
import uk.ac.ebi.fgpt.conan.model.ConanPipeline;
import uk.ac.ebi.fgpt.conan.model.ConanTask;
import uk.ac.ebi.fgpt.conan.model.context.ExecutionContext;
import uk.ac.ebi.fgpt.conan.model.param.ParamMap;
import uk.ac.ebi.fgpt.conan.properties.ConanProperties;
import uk.ac.ebi.fgpt.conan.service.DefaultExecutorService;
import uk.ac.ebi.fgpt.conan.service.DefaultProcessService;
import uk.ac.ebi.fgpt.conan.service.exception.TaskExecutionException;
import uk.ac.ebi.fgpt.conan.util.AbstractConanCLI;
import uk.ac.tgac.conan.core.util.JarUtils;
import uk.ac.tgac.rampart.util.CommandLineHelper;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
this.memory = commandLine.hasOption(OPT_MEMORY) ?
Integer.parseInt(commandLine.getOptionValue(OPT_MEMORY)) :
DEFAULT_MEMORY;
this.recursive = commandLine.hasOption(OPT_RECURSIVE);
this.single = commandLine.hasOption(OPT_SINGLE);
// Check for a single arg left on the command line
if (commandLine.getArgs().length != 1)
throw new ParseException("Unexpected number of arguments on the command line. Expected 1, found " +
commandLine.getArgs().length);
// This is the input directory containing libraries to analyse.
this.inputDir = new File(commandLine.getArgs()[0]);
}
@Override
protected ParamMap createArgMap() {
return this.args.getArgMap();
}
@Override
protected ConanPipeline createPipeline() throws IOException {
return new Jellyswarm.Pipeline(this.args, new DefaultExecutorService(new DefaultProcessService(), this.executionContext));
}
@Override
protected void printHelp() { | CommandLineHelper.printHelp( |
TGAC/RAMPART | src/test/java/uk/ac/tgac/rampart/stage/analyse/asm/selector/ScalingTest.java | // Path: src/main/java/uk/ac/tgac/rampart/stage/analyse/asm/stats/Scaling.java
// public class Scaling {
//
// public static double min(double[] a) {
//
// double min = 0.0;
//
// for(double v : a) {
// min = Math.min(v, min);
// }
//
// return min;
// }
//
// public static double max(double[] a) {
//
// double max = 0.0;
//
// for(double v : a) {
// max = Math.max(v, max);
// }
//
// return max;
// }
//
// public static void clear(double[] a) {
// for(int i = 0; i < a.length; i++) {
// a[i] = 0;
// }
// }
//
// public static void weight(double[] a, double weight) {
// for(int i = 0; i < a.length; i++) {
// a[i] *= weight;
// }
// }
//
// public static void standardScale(double[] a, boolean invert) {
//
// double min = min(a);
// double max = max(a);
//
// for (int i = 0; i < a.length; i++) {
//
// double delta = a[i] - min;
//
// double diff = max - min;
//
// double norm = delta / diff;
//
// double newVal = diff == 0.0 ? 0.5 : norm;
//
// a[i] = invert ? 1.0 - newVal : newVal;
// }
// }
//
// public static void deviationScale(double[] a, double mean) {
//
// double max = 0.0;
//
// for (int i = 0; i < a.length; i++) {
//
// double dev = Math.abs(a[i] - mean);
//
// max = Math.max(max, dev);
// }
//
// for (int i = 0; i < a.length; i++) {
//
// double dev = Math.abs(a[i] - mean);
//
// double norm = 1.0 - (dev / max);
//
// a[i] = 1.0 - norm;
// }
// }
//
// public static void percentageScale(double[] a, boolean invert) {
//
// for (int i = 0; i < a.length; i++) {
//
// double norm = a[i] / 100.0;
//
// a[i] = invert ? 1.0 - norm : norm;
// }
// }
// }
| import static org.junit.Assert.assertTrue;
import org.junit.Test;
import uk.ac.tgac.rampart.stage.analyse.asm.stats.Scaling;
import java.io.IOException; | /*
* RAMPART - Robust Automatic MultiPle AssembleR Toolkit
* Copyright (C) 2015 Daniel Mapleson - TGAC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.tgac.rampart.stage.analyse.asm.selector;
/**
* User: maplesod
* Date: 26/04/13
* Time: 10:57
*/
public class ScalingTest {
@Test
public void testStandardNormalise() throws IOException {
double[] a = new double[] {
851620,
746981,
637136,
581571,
521126,
485352
};
| // Path: src/main/java/uk/ac/tgac/rampart/stage/analyse/asm/stats/Scaling.java
// public class Scaling {
//
// public static double min(double[] a) {
//
// double min = 0.0;
//
// for(double v : a) {
// min = Math.min(v, min);
// }
//
// return min;
// }
//
// public static double max(double[] a) {
//
// double max = 0.0;
//
// for(double v : a) {
// max = Math.max(v, max);
// }
//
// return max;
// }
//
// public static void clear(double[] a) {
// for(int i = 0; i < a.length; i++) {
// a[i] = 0;
// }
// }
//
// public static void weight(double[] a, double weight) {
// for(int i = 0; i < a.length; i++) {
// a[i] *= weight;
// }
// }
//
// public static void standardScale(double[] a, boolean invert) {
//
// double min = min(a);
// double max = max(a);
//
// for (int i = 0; i < a.length; i++) {
//
// double delta = a[i] - min;
//
// double diff = max - min;
//
// double norm = delta / diff;
//
// double newVal = diff == 0.0 ? 0.5 : norm;
//
// a[i] = invert ? 1.0 - newVal : newVal;
// }
// }
//
// public static void deviationScale(double[] a, double mean) {
//
// double max = 0.0;
//
// for (int i = 0; i < a.length; i++) {
//
// double dev = Math.abs(a[i] - mean);
//
// max = Math.max(max, dev);
// }
//
// for (int i = 0; i < a.length; i++) {
//
// double dev = Math.abs(a[i] - mean);
//
// double norm = 1.0 - (dev / max);
//
// a[i] = 1.0 - norm;
// }
// }
//
// public static void percentageScale(double[] a, boolean invert) {
//
// for (int i = 0; i < a.length; i++) {
//
// double norm = a[i] / 100.0;
//
// a[i] = invert ? 1.0 - norm : norm;
// }
// }
// }
// Path: src/test/java/uk/ac/tgac/rampart/stage/analyse/asm/selector/ScalingTest.java
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import uk.ac.tgac.rampart.stage.analyse.asm.stats.Scaling;
import java.io.IOException;
/*
* RAMPART - Robust Automatic MultiPle AssembleR Toolkit
* Copyright (C) 2015 Daniel Mapleson - TGAC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.tgac.rampart.stage.analyse.asm.selector;
/**
* User: maplesod
* Date: 26/04/13
* Time: 10:57
*/
public class ScalingTest {
@Test
public void testStandardNormalise() throws IOException {
double[] a = new double[] {
851620,
746981,
637136,
581571,
521126,
485352
};
| Scaling.standardScale(a, true); |
TGAC/RAMPART | src/main/java/uk/ac/tgac/rampart/stage/analyse/asm/AnalyseMassAssemblies.java | // Path: src/main/java/uk/ac/tgac/rampart/stage/analyse/asm/analysers/AssemblyAnalyser.java
// public interface AssemblyAnalyser extends Service {
//
// /**
// * Checks whether or not this assembly analyser looks properly configured for the system
// * @param executionContext The environment in which to check if the process is operational
// * @return True if analyser is operational, false otherwise
// */
// boolean isOperational(ExecutionContext executionContext);
//
// /**
// * Execute this assembly analysis
// * @param assemblies The list of assemblies to analyse
// * @param outputDir The output directory in which to produce files
// * @param jobPrefix The prefix to apply to any scheduled jobs executed as part of this analysis
// * @param ces The conan execution service
// * @return A list of job execution results from the executed jobs
// * @throws InterruptedException Thrown if user has interrupted the process during execution
// * @throws ProcessExecutionException Thrown if there is an issue during execution of an external process
// * @throws ConanParameterException Thrown if there was an issue configuring the parameters for the external process
// * @throws IOException Thrown if there was an issue handling files before or after the external process is run
// */
// List<ExecutionResult> execute(List<File> assemblies, File outputDir, String jobPrefix, ConanExecutorService ces)
// throws InterruptedException, ProcessExecutionException, ConanParameterException, IOException;
//
// /**
// * Set args for this assembly analyser
// * @param args The args describing how to analyse the provided assemblies
// */
// void setArgs(AnalyseAssembliesArgs.ToolArgs args);
//
// /**
// * Used to override whether or not this process should run parallel
// * @param runParallel
// */
// void setRunParallel(boolean runParallel);
//
// /**
// * Updates the provided table with information from this analysis
// * @param table The table to update with new information
// * @param reportDir The location in which reports from this analysis might be located
// * @throws IOException Thrown if there we issues accessing all the necessary files
// */
// void updateTable(AssemblyStatsTable table, File reportDir)
// throws IOException;
//
// /**
// * If this assembly analysis runs quickly, then we might do more work with it.
// * @return True if this process runs quickly, false if not.
// */
// boolean isFast();
//
// /**
// * Sets the executor service
// * @param ces The conan execution service
// */
// void setConanExecutorService(ConanExecutorService ces);
// }
| import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import uk.ac.ebi.fgpt.conan.core.context.DefaultExecutionResult;
import uk.ac.ebi.fgpt.conan.core.context.DefaultTaskResult;
import uk.ac.ebi.fgpt.conan.core.param.ArgValidator;
import uk.ac.ebi.fgpt.conan.core.param.ParameterBuilder;
import uk.ac.ebi.fgpt.conan.core.process.AbstractConanProcess;
import uk.ac.ebi.fgpt.conan.model.context.ExecutionContext;
import uk.ac.ebi.fgpt.conan.model.context.ExecutionResult;
import uk.ac.ebi.fgpt.conan.model.context.ResourceUsage;
import uk.ac.ebi.fgpt.conan.model.context.TaskResult;
import uk.ac.ebi.fgpt.conan.model.param.ConanParameter;
import uk.ac.ebi.fgpt.conan.service.ConanExecutorService;
import uk.ac.ebi.fgpt.conan.service.exception.ConanParameterException;
import uk.ac.ebi.fgpt.conan.service.exception.ProcessExecutionException;
import uk.ac.tgac.conan.core.data.Organism;
import uk.ac.tgac.conan.process.asm.Assembler;
import uk.ac.tgac.rampart.stage.*;
import uk.ac.tgac.rampart.stage.analyse.asm.analysers.AssemblyAnalyser;
import java.io.File;
import java.io.IOException;
import java.util.*; | /*
* RAMPART - Robust Automatic MultiPle AssembleR Toolkit
* Copyright (C) 2015 Daniel Mapleson - TGAC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.tgac.rampart.stage.analyse.asm;
/**
* Created with IntelliJ IDEA.
* User: maplesod
* Date: 21/01/14
* Time: 10:45
* To change this template use File | Settings | File Templates.
*/
public class AnalyseMassAssemblies extends RampartProcess {
private static Logger log = LoggerFactory.getLogger(AnalyseMassAssemblies.class);
public AnalyseMassAssemblies() {
this(null);
}
public AnalyseMassAssemblies(ConanExecutorService ces) {
this(ces, new Args());
}
public AnalyseMassAssemblies(ConanExecutorService ces, Args args) {
super(ces, args);
}
public Args getArgs() {
return (Args)this.getProcessArgs();
}
@Override
public String getName() {
return "Analyse_Assemblies";
}
@Override
public boolean isOperational(ExecutionContext executionContext) {
// Create requested services | // Path: src/main/java/uk/ac/tgac/rampart/stage/analyse/asm/analysers/AssemblyAnalyser.java
// public interface AssemblyAnalyser extends Service {
//
// /**
// * Checks whether or not this assembly analyser looks properly configured for the system
// * @param executionContext The environment in which to check if the process is operational
// * @return True if analyser is operational, false otherwise
// */
// boolean isOperational(ExecutionContext executionContext);
//
// /**
// * Execute this assembly analysis
// * @param assemblies The list of assemblies to analyse
// * @param outputDir The output directory in which to produce files
// * @param jobPrefix The prefix to apply to any scheduled jobs executed as part of this analysis
// * @param ces The conan execution service
// * @return A list of job execution results from the executed jobs
// * @throws InterruptedException Thrown if user has interrupted the process during execution
// * @throws ProcessExecutionException Thrown if there is an issue during execution of an external process
// * @throws ConanParameterException Thrown if there was an issue configuring the parameters for the external process
// * @throws IOException Thrown if there was an issue handling files before or after the external process is run
// */
// List<ExecutionResult> execute(List<File> assemblies, File outputDir, String jobPrefix, ConanExecutorService ces)
// throws InterruptedException, ProcessExecutionException, ConanParameterException, IOException;
//
// /**
// * Set args for this assembly analyser
// * @param args The args describing how to analyse the provided assemblies
// */
// void setArgs(AnalyseAssembliesArgs.ToolArgs args);
//
// /**
// * Used to override whether or not this process should run parallel
// * @param runParallel
// */
// void setRunParallel(boolean runParallel);
//
// /**
// * Updates the provided table with information from this analysis
// * @param table The table to update with new information
// * @param reportDir The location in which reports from this analysis might be located
// * @throws IOException Thrown if there we issues accessing all the necessary files
// */
// void updateTable(AssemblyStatsTable table, File reportDir)
// throws IOException;
//
// /**
// * If this assembly analysis runs quickly, then we might do more work with it.
// * @return True if this process runs quickly, false if not.
// */
// boolean isFast();
//
// /**
// * Sets the executor service
// * @param ces The conan execution service
// */
// void setConanExecutorService(ConanExecutorService ces);
// }
// Path: src/main/java/uk/ac/tgac/rampart/stage/analyse/asm/AnalyseMassAssemblies.java
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import uk.ac.ebi.fgpt.conan.core.context.DefaultExecutionResult;
import uk.ac.ebi.fgpt.conan.core.context.DefaultTaskResult;
import uk.ac.ebi.fgpt.conan.core.param.ArgValidator;
import uk.ac.ebi.fgpt.conan.core.param.ParameterBuilder;
import uk.ac.ebi.fgpt.conan.core.process.AbstractConanProcess;
import uk.ac.ebi.fgpt.conan.model.context.ExecutionContext;
import uk.ac.ebi.fgpt.conan.model.context.ExecutionResult;
import uk.ac.ebi.fgpt.conan.model.context.ResourceUsage;
import uk.ac.ebi.fgpt.conan.model.context.TaskResult;
import uk.ac.ebi.fgpt.conan.model.param.ConanParameter;
import uk.ac.ebi.fgpt.conan.service.ConanExecutorService;
import uk.ac.ebi.fgpt.conan.service.exception.ConanParameterException;
import uk.ac.ebi.fgpt.conan.service.exception.ProcessExecutionException;
import uk.ac.tgac.conan.core.data.Organism;
import uk.ac.tgac.conan.process.asm.Assembler;
import uk.ac.tgac.rampart.stage.*;
import uk.ac.tgac.rampart.stage.analyse.asm.analysers.AssemblyAnalyser;
import java.io.File;
import java.io.IOException;
import java.util.*;
/*
* RAMPART - Robust Automatic MultiPle AssembleR Toolkit
* Copyright (C) 2015 Daniel Mapleson - TGAC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.tgac.rampart.stage.analyse.asm;
/**
* Created with IntelliJ IDEA.
* User: maplesod
* Date: 21/01/14
* Time: 10:45
* To change this template use File | Settings | File Templates.
*/
public class AnalyseMassAssemblies extends RampartProcess {
private static Logger log = LoggerFactory.getLogger(AnalyseMassAssemblies.class);
public AnalyseMassAssemblies() {
this(null);
}
public AnalyseMassAssemblies(ConanExecutorService ces) {
this(ces, new Args());
}
public AnalyseMassAssemblies(ConanExecutorService ces, Args args) {
super(ces, args);
}
public Args getArgs() {
return (Args)this.getProcessArgs();
}
@Override
public String getName() {
return "Analyse_Assemblies";
}
@Override
public boolean isOperational(ExecutionContext executionContext) {
// Create requested services | Set<AssemblyAnalyser> requestedServices = this.getArgs().getAssemblyAnalysers(); |
TGAC/RAMPART | src/test/java/uk/ac/tgac/rampart/RampartConfigTest.java | // Path: src/main/java/uk/ac/tgac/rampart/stage/RampartStageList.java
// public class RampartStageList extends ArrayList<RampartStage> {
//
// private Set<RampartStage> distinctStages;
//
// public RampartStageList() {
// super();
// this.distinctStages = new HashSet<>();
// }
//
//
// @Override
// public void add(int index, RampartStage stage) {
// throw new UnsupportedOperationException("Cannot insert stages");
// }
//
//
// @Override
// public boolean add(RampartStage stage) {
//
// if (distinctStages.contains(stage)) {
// throw new IllegalArgumentException("Cannot add duplicated stage to RAMPART stage list");
// }
//
// this.distinctStages.add(stage);
// boolean result = super.add(stage);
//
// this.sort();
//
// return result;
// }
//
// @Override
// public boolean addAll(int index, Collection<? extends RampartStage> stages) {
// throw new UnsupportedOperationException("Cannot insert collection of stages");
// }
//
// public List<AbstractConanProcess> createProcesses(ConanExecutorService ces) {
//
// List<AbstractConanProcess> processes = new ArrayList<>();
//
// for(RampartStage stage : this) {
//
// if(stage.getArgs() != null) {
// processes.add(stage.create(ces));
// }
// }
//
// return processes;
// }
//
// public RampartStage get(RampartStage stageToFind) {
//
// for(RampartStage stage : this) {
// if (stage == stageToFind) {
// return stage;
// }
// }
//
// return null;
// }
//
// public List<ConanProcess> getExternalTools() {
//
// List<ConanProcess> processes = new ArrayList<>();
//
// for(RampartStage stage : this) {
// processes.addAll(stage.getArgs().getExternalProcesses());
// }
//
// return processes;
// }
//
// public static RampartStageList parse(String stages) {
//
// if (stages.trim().equalsIgnoreCase("ALL")) {
// stages = RampartStage.getFullListAsString();
// }
//
// String[] stageArray = stages.split(",");
//
// RampartStageList stageList = new RampartStageList();
//
// if (stageArray != null && stageArray.length != 0) {
// for(String stage : stageArray) {
// stageList.add(RampartStage.valueOf(stage.trim().toUpperCase()));
// }
// }
//
// return stageList;
// }
//
//
// public String toString() {
//
// return StringUtils.join(this, ",");
// }
//
// public void setArgsIfPresent(RampartStage stage, RampartStageArgs args) {
//
// if (args != null) {
// for(RampartStage rs : this) {
// if (rs == stage) {
// rs.setArgs(args);
// }
// }
// }
// }
//
// public void sort() {
//
// Collections.sort(this, new Comparator<RampartStage>() {
// @Override
// public int compare(RampartStage o1, RampartStage o2) {
// return o1.ordinal() - o2.ordinal();
// }
// });
// }
//
// }
| import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import uk.ac.ebi.fgpt.conan.service.exception.TaskExecutionException;
import uk.ac.tgac.rampart.stage.RampartStageList;
import java.io.File;
import java.io.IOException;
import static junit.framework.TestCase.assertTrue; | /*
* RAMPART - Robust Automatic MultiPle AssembleR Toolkit
* Copyright (C) 2015 Daniel Mapleson - TGAC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.tgac.rampart;
/**
* Created with IntelliJ IDEA.
* User: maplesod
* Date: 12/12/13
* Time: 16:31
* To change this template use File | Settings | File Templates.
*/
public class RampartConfigTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void testConfigLoad() throws IOException {
File cfgFile = FileUtils.toFile(this.getClass().getResource("/config/test_rampart_config.xml"));
File outDir = temp.newFolder("configTest");
String jobPrefix = "configTestJob";
| // Path: src/main/java/uk/ac/tgac/rampart/stage/RampartStageList.java
// public class RampartStageList extends ArrayList<RampartStage> {
//
// private Set<RampartStage> distinctStages;
//
// public RampartStageList() {
// super();
// this.distinctStages = new HashSet<>();
// }
//
//
// @Override
// public void add(int index, RampartStage stage) {
// throw new UnsupportedOperationException("Cannot insert stages");
// }
//
//
// @Override
// public boolean add(RampartStage stage) {
//
// if (distinctStages.contains(stage)) {
// throw new IllegalArgumentException("Cannot add duplicated stage to RAMPART stage list");
// }
//
// this.distinctStages.add(stage);
// boolean result = super.add(stage);
//
// this.sort();
//
// return result;
// }
//
// @Override
// public boolean addAll(int index, Collection<? extends RampartStage> stages) {
// throw new UnsupportedOperationException("Cannot insert collection of stages");
// }
//
// public List<AbstractConanProcess> createProcesses(ConanExecutorService ces) {
//
// List<AbstractConanProcess> processes = new ArrayList<>();
//
// for(RampartStage stage : this) {
//
// if(stage.getArgs() != null) {
// processes.add(stage.create(ces));
// }
// }
//
// return processes;
// }
//
// public RampartStage get(RampartStage stageToFind) {
//
// for(RampartStage stage : this) {
// if (stage == stageToFind) {
// return stage;
// }
// }
//
// return null;
// }
//
// public List<ConanProcess> getExternalTools() {
//
// List<ConanProcess> processes = new ArrayList<>();
//
// for(RampartStage stage : this) {
// processes.addAll(stage.getArgs().getExternalProcesses());
// }
//
// return processes;
// }
//
// public static RampartStageList parse(String stages) {
//
// if (stages.trim().equalsIgnoreCase("ALL")) {
// stages = RampartStage.getFullListAsString();
// }
//
// String[] stageArray = stages.split(",");
//
// RampartStageList stageList = new RampartStageList();
//
// if (stageArray != null && stageArray.length != 0) {
// for(String stage : stageArray) {
// stageList.add(RampartStage.valueOf(stage.trim().toUpperCase()));
// }
// }
//
// return stageList;
// }
//
//
// public String toString() {
//
// return StringUtils.join(this, ",");
// }
//
// public void setArgsIfPresent(RampartStage stage, RampartStageArgs args) {
//
// if (args != null) {
// for(RampartStage rs : this) {
// if (rs == stage) {
// rs.setArgs(args);
// }
// }
// }
// }
//
// public void sort() {
//
// Collections.sort(this, new Comparator<RampartStage>() {
// @Override
// public int compare(RampartStage o1, RampartStage o2) {
// return o1.ordinal() - o2.ordinal();
// }
// });
// }
//
// }
// Path: src/test/java/uk/ac/tgac/rampart/RampartConfigTest.java
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import uk.ac.ebi.fgpt.conan.service.exception.TaskExecutionException;
import uk.ac.tgac.rampart.stage.RampartStageList;
import java.io.File;
import java.io.IOException;
import static junit.framework.TestCase.assertTrue;
/*
* RAMPART - Robust Automatic MultiPle AssembleR Toolkit
* Copyright (C) 2015 Daniel Mapleson - TGAC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.tgac.rampart;
/**
* Created with IntelliJ IDEA.
* User: maplesod
* Date: 12/12/13
* Time: 16:31
* To change this template use File | Settings | File Templates.
*/
public class RampartConfigTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void testConfigLoad() throws IOException {
File cfgFile = FileUtils.toFile(this.getClass().getResource("/config/test_rampart_config.xml"));
File outDir = temp.newFolder("configTest");
String jobPrefix = "configTestJob";
| RampartConfig args = new RampartConfig(cfgFile, outDir, jobPrefix, RampartStageList.parse("ALL"), null, null, true); |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/CommonController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestBody;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class CommonController {
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/CommonController.java
import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestBody;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class CommonController {
| @RequestMapping(value = "/openTabs.json", method = RequestMethod.GET) |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/CommonController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestBody;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class CommonController {
@RequestMapping(value = "/openTabs.json", method = RequestMethod.GET) | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/CommonController.java
import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestBody;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class CommonController {
@RequestMapping(value = "/openTabs.json", method = RequestMethod.GET) | public ServiceResponse getTabRecord(@RequestParam(value = "projectId", required = false) Long projectId, |
gugemichael/nesty | commons/src/main/java/org/nesty/commons/annotations/RequestMapping.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
| import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package org.nesty.commons.annotations;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequestMapping {
String value(); | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
// Path: commons/src/main/java/org/nesty/commons/annotations/RequestMapping.java
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package org.nesty.commons.annotations;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequestMapping {
String value(); | RequestMethod method() default RequestMethod.GET; |
gugemichael/nesty | commons/src/main/java/org/nesty/commons/annotations/RequestMapping.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
| import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package org.nesty.commons.annotations;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequestMapping {
String value();
RequestMethod method() default RequestMethod.GET; | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
// Path: commons/src/main/java/org/nesty/commons/annotations/RequestMapping.java
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package org.nesty.commons.annotations;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequestMapping {
String value();
RequestMethod method() default RequestMethod.GET; | String consumes() default HttpConstants.HEADER_CONTENT_TYPE_JSON; |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/response/HttpResponseBuilder.java | // Path: commons/src/main/java/org/nesty/commons/constant/NestyConstants.java
// public class NestyConstants {
//
// public static final String NESTY_SERVER = "Nesty";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/utils/SerializeUtils.java
// public class SerializeUtils {
//
// private static final Charset CHARSET = Charsets.UTF_8;
//
// private static final Gson GSON = new GsonBuilder().create();
//
// public static byte[] encode(Object stuff) {
// return GSON.toJson(stuff).getBytes(CHARSET);
// }
//
// public static Object decode(String stuff, Class<?> clazz) throws SerializeException {
// try {
// return GSON.fromJson(stuff, clazz);
// } catch (JsonSyntaxException e) {
// throw new SerializeException(String.format("%s decode exception", stuff));
// }
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
| import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.NestyConstants;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.utils.SerializeUtils;
import org.nesty.core.server.rest.HttpContext; | package org.nesty.core.server.rest.response;
/**
* Build an DefaultFullHttpResponse {@link DefaultFullHttpResponse}
*
* [Author] Michael
* [Date] March 04, 2016
*/
public class HttpResponseBuilder {
// if no content in DefaultFullHttpResponse we will fill empty body
private static final byte[] uselessBuffer = SerializeUtils.encode(new EMPTY());
| // Path: commons/src/main/java/org/nesty/commons/constant/NestyConstants.java
// public class NestyConstants {
//
// public static final String NESTY_SERVER = "Nesty";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/utils/SerializeUtils.java
// public class SerializeUtils {
//
// private static final Charset CHARSET = Charsets.UTF_8;
//
// private static final Gson GSON = new GsonBuilder().create();
//
// public static byte[] encode(Object stuff) {
// return GSON.toJson(stuff).getBytes(CHARSET);
// }
//
// public static Object decode(String stuff, Class<?> clazz) throws SerializeException {
// try {
// return GSON.fromJson(stuff, clazz);
// } catch (JsonSyntaxException e) {
// throw new SerializeException(String.format("%s decode exception", stuff));
// }
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/response/HttpResponseBuilder.java
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.NestyConstants;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.utils.SerializeUtils;
import org.nesty.core.server.rest.HttpContext;
package org.nesty.core.server.rest.response;
/**
* Build an DefaultFullHttpResponse {@link DefaultFullHttpResponse}
*
* [Author] Michael
* [Date] March 04, 2016
*/
public class HttpResponseBuilder {
// if no content in DefaultFullHttpResponse we will fill empty body
private static final byte[] uselessBuffer = SerializeUtils.encode(new EMPTY());
| public static DefaultFullHttpResponse create(HttpContext httpContext, HttpResponseStatus status) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/ControllerRouter.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/controller/URLController.java
// public class URLController extends Hitcounter {
//
// // target class
// private ControllerClassDescriptor provider;
// // target method
// private ControllerMethodDescriptor procedure;
// // internal controller sign. only for root-path
// private boolean internal = false;
//
// private URLController() {
//
// }
//
// public static URLController fromProvider(String URI, Class<?> providerClass, Method procedure) {
// URLController handler = new URLController();
// handler.provider = new ControllerClassDescriptor(providerClass);
// handler.procedure = new ControllerMethodDescriptor(URI, handler.provider, procedure);
// return handler;
// }
//
// public URLController internal() {
// this.internal = true;
// return this;
// }
//
// public boolean isInternal() {
// return this.internal;
// }
//
// public HttpResult call(HttpContext context) {
// /**
// * make new controller class instance with every http request. because
// * of we desire every request may has own context variables and status.
// *
// * TODO : This newInstance() need a empty param default constructor.
// *
// */
//
// try {
// Object result = procedure.invoke(context);
// if (result != null && !result.getClass().isPrimitive())
// return new HttpResult(ResultCode.SUCCESS, result);
// else
// return new HttpResult(ResultCode.RESPONSE_NOT_VALID);
// } catch (ControllerParamsNotMatchException e) {
// return new HttpResult(ResultCode.PARAMS_NOT_MATCHED);
// } catch (ControllerParamsParsedException e) {
// return new HttpResult(ResultCode.PARAMS_CONVERT_ERROR);
// }
// }
//
// @Override
// public String toString() {
// return String.format("provider=%s, procedure=%s", provider.getClazz().getCanonicalName(), procedure.getMethod().getName());
// }
// }
| import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.controller.URLController;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; | package org.nesty.core.server.rest;
/**
* Routeable Controller mapping
*
* Author : Michael
* Date : March 07, 2016
*/
public class ControllerRouter {
/**
* first index layer. indexd by HttpMethod and URL terms length
*
* our max supportted URL terms is 512
*/
private final URLMapper[][] mapper = new URLMapper[RequestMethod.UNKOWN.ordinal()][512];
/**
* get specified resource's controller or null if it don't exist
*
* @param resource url anaylzed resource
* @return controller instance or null if it don't exist
*/ | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/controller/URLController.java
// public class URLController extends Hitcounter {
//
// // target class
// private ControllerClassDescriptor provider;
// // target method
// private ControllerMethodDescriptor procedure;
// // internal controller sign. only for root-path
// private boolean internal = false;
//
// private URLController() {
//
// }
//
// public static URLController fromProvider(String URI, Class<?> providerClass, Method procedure) {
// URLController handler = new URLController();
// handler.provider = new ControllerClassDescriptor(providerClass);
// handler.procedure = new ControllerMethodDescriptor(URI, handler.provider, procedure);
// return handler;
// }
//
// public URLController internal() {
// this.internal = true;
// return this;
// }
//
// public boolean isInternal() {
// return this.internal;
// }
//
// public HttpResult call(HttpContext context) {
// /**
// * make new controller class instance with every http request. because
// * of we desire every request may has own context variables and status.
// *
// * TODO : This newInstance() need a empty param default constructor.
// *
// */
//
// try {
// Object result = procedure.invoke(context);
// if (result != null && !result.getClass().isPrimitive())
// return new HttpResult(ResultCode.SUCCESS, result);
// else
// return new HttpResult(ResultCode.RESPONSE_NOT_VALID);
// } catch (ControllerParamsNotMatchException e) {
// return new HttpResult(ResultCode.PARAMS_NOT_MATCHED);
// } catch (ControllerParamsParsedException e) {
// return new HttpResult(ResultCode.PARAMS_CONVERT_ERROR);
// }
// }
//
// @Override
// public String toString() {
// return String.format("provider=%s, procedure=%s", provider.getClazz().getCanonicalName(), procedure.getMethod().getName());
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/ControllerRouter.java
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.controller.URLController;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
package org.nesty.core.server.rest;
/**
* Routeable Controller mapping
*
* Author : Michael
* Date : March 07, 2016
*/
public class ControllerRouter {
/**
* first index layer. indexd by HttpMethod and URL terms length
*
* our max supportted URL terms is 512
*/
private final URLMapper[][] mapper = new URLMapper[RequestMethod.UNKOWN.ordinal()][512];
/**
* get specified resource's controller or null if it don't exist
*
* @param resource url anaylzed resource
* @return controller instance or null if it don't exist
*/ | public URLController findURLController(URLResource resource) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
| import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.RequestMethod;
import java.util.Map; | package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public interface HttpRequestVisitor {
String visitRemoteAddress();
String visitURI();
String[] visitTerms();
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.RequestMethod;
import java.util.Map;
package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public interface HttpRequestVisitor {
String visitRemoteAddress();
String visitURI();
String[] visitTerms();
| RequestMethod visitHttpMethod(); |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/URLResource.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
| import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.util.ArrayList;
import java.util.List; | package org.nesty.core.server.rest;
/**
* Represent one URI resource. include http uri and http method
*
* Author Michael on 03/03/2016.
*/
public class URLResource {
// variable flag
public static final char VARIABLE = '{';
// resource identifier
private URLResourceIdentifier identifier;
private URLResource() {
}
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/URLResource.java
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.util.ArrayList;
import java.util.List;
package org.nesty.core.server.rest;
/**
* Represent one URI resource. include http uri and http method
*
* Author Michael on 03/03/2016.
*/
public class URLResource {
// variable flag
public static final char VARIABLE = '{';
// resource identifier
private URLResourceIdentifier identifier;
private URLResource() {
}
| public static URLResource fromHttp(String url, RequestMethod requestMethod) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/URLResource.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
| import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.util.ArrayList;
import java.util.List; | }
public List<String> fragments() {
return identifier.fragments;
}
@Override
public String toString() {
return identifier.toString();
}
@Override
public int hashCode() {
return identifier.hashCode();
}
@Override
public boolean equals(Object other) {
return !(other == null || !(other instanceof URLResource)) && identifier.equals(((URLResource) other).identifier);
}
/**
* URLResource uniqu identifier member. used for URLResource
* equals and hashcode id
*/
static class URLResourceIdentifier {
protected List<String> fragments = new ArrayList<>(64);
protected RequestMethod requestMethod;
public static URLResourceIdentifier analyse(String url) { | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/URLResource.java
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.util.ArrayList;
import java.util.List;
}
public List<String> fragments() {
return identifier.fragments;
}
@Override
public String toString() {
return identifier.toString();
}
@Override
public int hashCode() {
return identifier.hashCode();
}
@Override
public boolean equals(Object other) {
return !(other == null || !(other instanceof URLResource)) && identifier.equals(((URLResource) other).identifier);
}
/**
* URLResource uniqu identifier member. used for URLResource
* equals and hashcode id
*/
static class URLResourceIdentifier {
protected List<String> fragments = new ArrayList<>(64);
protected RequestMethod requestMethod;
public static URLResourceIdentifier analyse(String url) { | url = HttpUtils.truncateUrl(url); |
gugemichael/nesty | commons/src/main/java/org/nesty/commons/writer/DailyRollFileWriter.java | // Path: commons/src/main/java/org/nesty/commons/utils/Time.java
// public class Time {
//
// private int year;
// private int month;
// private int day;
// private int hour;
// private int minute;
// private int second;
// private int microSecond;
//
// private Time() {
// }
//
// public int getYear() {
// return year;
// }
//
// public Time setYear(int year) {
// this.year = year;
// return this;
// }
//
// public int getMonth() {
// return month;
// }
//
// public Time setMonth(int month) {
// this.month = month;
// return this;
// }
//
// public int getDay() {
// return day;
// }
//
// public Time setDay(int day) {
// this.day = day;
// return this;
// }
//
// public int getHour() {
// return hour;
// }
//
// public Time setHour(int hour) {
// this.hour = hour;
// return this;
// }
//
// public int getMinute() {
// return minute;
// }
//
// public Time setMinute(int minute) {
// this.minute = minute;
// return this;
// }
//
// public int getSecond() {
// return second;
// }
//
// public Time setSecond(int second) {
// this.second = second;
// return this;
// }
//
// public int getMicroSecond() {
// return microSecond;
// }
//
// public Time setMicroSecond(int microSecond) {
// this.microSecond = microSecond;
// return this;
// }
//
// public boolean diffDay(Time t) {
// return t == null || t.year != year || t.month != month || t.day != day;
// }
//
// public boolean diffMiniute(Time t) {
// return t == null || t.year != year || t.month != month || t.day != day || t.hour != hour || t.minute != minute;
// }
//
// public boolean diffSecond(Time t) {
// return t == null || t.year != year || t.month != month || t.day != day || t.hour != hour || t.minute != minute || t.second != second;
// }
//
// @Override
// public String toString() {
// return String.format("%d-%d-%d %d:%d:%d.%d", year, month, day, hour, minute, second, microSecond);
// }
//
// public static Time fetch() {
// Calendar calender = Calendar.getInstance();
// return new Time().setYear(calender.get(Calendar.YEAR)).setMonth(calender.get(Calendar.MONTH) + 1)
// .setDay(calender.get(Calendar.DAY_OF_MONTH)).setHour(calender.get(Calendar.HOUR_OF_DAY))
// .setMinute(calender.get(Calendar.MINUTE)).setSecond(calender.get(Calendar.SECOND))
// .setMicroSecond(calender.get(Calendar.MILLISECOND));
// }
//
// /**
// * return current unix timestamp seconds
// *
// * @return unix timestamp
// */
// public static long getUnixStamp() {
// return System.currentTimeMillis() / 1000L;
// }
// }
| import org.nesty.commons.utils.Time;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock; | package org.nesty.commons.writer;
public class DailyRollFileWriter extends GenericFileWriter {
// rotate file name carry with daytime
private static final String ROTATE_FILE_PATTERN = "%s.%d-%02d-%02d";
// rotate file name if conflict with default daytime rotate file, carry with autonumber
private static final String ROTATE_FILE_CONFLICT_PATTERN = "%s.%d";
// rotate locking
@SuppressWarnings("unused")
private ReentrantLock lock = new ReentrantLock();
// file timestamp | // Path: commons/src/main/java/org/nesty/commons/utils/Time.java
// public class Time {
//
// private int year;
// private int month;
// private int day;
// private int hour;
// private int minute;
// private int second;
// private int microSecond;
//
// private Time() {
// }
//
// public int getYear() {
// return year;
// }
//
// public Time setYear(int year) {
// this.year = year;
// return this;
// }
//
// public int getMonth() {
// return month;
// }
//
// public Time setMonth(int month) {
// this.month = month;
// return this;
// }
//
// public int getDay() {
// return day;
// }
//
// public Time setDay(int day) {
// this.day = day;
// return this;
// }
//
// public int getHour() {
// return hour;
// }
//
// public Time setHour(int hour) {
// this.hour = hour;
// return this;
// }
//
// public int getMinute() {
// return minute;
// }
//
// public Time setMinute(int minute) {
// this.minute = minute;
// return this;
// }
//
// public int getSecond() {
// return second;
// }
//
// public Time setSecond(int second) {
// this.second = second;
// return this;
// }
//
// public int getMicroSecond() {
// return microSecond;
// }
//
// public Time setMicroSecond(int microSecond) {
// this.microSecond = microSecond;
// return this;
// }
//
// public boolean diffDay(Time t) {
// return t == null || t.year != year || t.month != month || t.day != day;
// }
//
// public boolean diffMiniute(Time t) {
// return t == null || t.year != year || t.month != month || t.day != day || t.hour != hour || t.minute != minute;
// }
//
// public boolean diffSecond(Time t) {
// return t == null || t.year != year || t.month != month || t.day != day || t.hour != hour || t.minute != minute || t.second != second;
// }
//
// @Override
// public String toString() {
// return String.format("%d-%d-%d %d:%d:%d.%d", year, month, day, hour, minute, second, microSecond);
// }
//
// public static Time fetch() {
// Calendar calender = Calendar.getInstance();
// return new Time().setYear(calender.get(Calendar.YEAR)).setMonth(calender.get(Calendar.MONTH) + 1)
// .setDay(calender.get(Calendar.DAY_OF_MONTH)).setHour(calender.get(Calendar.HOUR_OF_DAY))
// .setMinute(calender.get(Calendar.MINUTE)).setSecond(calender.get(Calendar.SECOND))
// .setMicroSecond(calender.get(Calendar.MILLISECOND));
// }
//
// /**
// * return current unix timestamp seconds
// *
// * @return unix timestamp
// */
// public static long getUnixStamp() {
// return System.currentTimeMillis() / 1000L;
// }
// }
// Path: commons/src/main/java/org/nesty/commons/writer/DailyRollFileWriter.java
import org.nesty.commons.utils.Time;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
package org.nesty.commons.writer;
public class DailyRollFileWriter extends GenericFileWriter {
// rotate file name carry with daytime
private static final String ROTATE_FILE_PATTERN = "%s.%d-%02d-%02d";
// rotate file name if conflict with default daytime rotate file, carry with autonumber
private static final String ROTATE_FILE_CONFLICT_PATTERN = "%s.%d";
// rotate locking
@SuppressWarnings("unused")
private ReentrantLock lock = new ReentrantLock();
// file timestamp | private volatile Time lastest; |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/ModelController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpSession.java
// public abstract class HttpSession {
//
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private long creationTime = System.currentTimeMillis();
//
// public HttpSession() {
//
// }
//
// public String getId() {
// return getRequestId();
// }
//
// public long getCreationTime() {
// return creationTime;
// }
//
// public long getLastAccessedTime() {
// // TODO : this time will updated by long connection
// //
// return creationTime;
// }
//
// public int getMaxInactiveInterval() {
// throw new NotImplementedException();
// }
//
// public void setMaxInactiveInterval(int interval) {
// throw new NotImplementedException();
// }
//
// public Object getAttribute(String name) {
// Object value;
// if ((value = getHttpParams().get(name)) != null)
// return value;
// if ((value = getHttpAttributes().get(name)) != null)
// return value;
// return null;
// }
//
// public Object getValue(String name) {
// return getAttribute(name);
// }
//
// public Enumeration<String> getAttributeNames() {
// return new Enumeration<String>() {
// Iterator<String> firest = getHttpParams().keySet().iterator();
// Iterator<String> second = getHttpAttributes().keySet().iterator();
//
// @Override
// public boolean hasMoreElements() {
// return firest.hasNext() || second.hasNext();
// }
//
// @Override
// public String nextElement() {
// try {
// return firest.next();
// } catch (NoSuchElementException e) {
// return second.next();
// }
// }
// };
// }
//
// public String[] getValueNames() {
// String[] arr = new String[getHttpParams().keySet().size() + getHttpAttributes().keySet().size()];
// Enumeration<String> names = getAttributeNames();
// int index = 0;
// while (names.hasMoreElements())
// arr[index++] = names.nextElement();
// return arr;
// }
//
// public void setAttribute(String name, Object value) {
// getHttpAttributes().put(name, value);
// }
//
// public void putValue(String name, Object value) {
// setAttribute(name, value);
// }
//
// public void removeAttribute(String name) {
// getHttpAttributes().remove(name);
// getHttpParams().remove(name);
// }
//
// public void removeValue(String name) {
// removeAttribute(name);
// }
//
// public void invalidate() {
// getHttpAttributes().clear();
// }
//
// public boolean isNew() {
// return true;
// }
//
// public abstract String getRequestId();
//
// public abstract Map<String, Object> getHttpAttributes();
//
// public abstract Map<String, String> getHttpParams();
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.HttpSession;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class ModelController {
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpSession.java
// public abstract class HttpSession {
//
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private long creationTime = System.currentTimeMillis();
//
// public HttpSession() {
//
// }
//
// public String getId() {
// return getRequestId();
// }
//
// public long getCreationTime() {
// return creationTime;
// }
//
// public long getLastAccessedTime() {
// // TODO : this time will updated by long connection
// //
// return creationTime;
// }
//
// public int getMaxInactiveInterval() {
// throw new NotImplementedException();
// }
//
// public void setMaxInactiveInterval(int interval) {
// throw new NotImplementedException();
// }
//
// public Object getAttribute(String name) {
// Object value;
// if ((value = getHttpParams().get(name)) != null)
// return value;
// if ((value = getHttpAttributes().get(name)) != null)
// return value;
// return null;
// }
//
// public Object getValue(String name) {
// return getAttribute(name);
// }
//
// public Enumeration<String> getAttributeNames() {
// return new Enumeration<String>() {
// Iterator<String> firest = getHttpParams().keySet().iterator();
// Iterator<String> second = getHttpAttributes().keySet().iterator();
//
// @Override
// public boolean hasMoreElements() {
// return firest.hasNext() || second.hasNext();
// }
//
// @Override
// public String nextElement() {
// try {
// return firest.next();
// } catch (NoSuchElementException e) {
// return second.next();
// }
// }
// };
// }
//
// public String[] getValueNames() {
// String[] arr = new String[getHttpParams().keySet().size() + getHttpAttributes().keySet().size()];
// Enumeration<String> names = getAttributeNames();
// int index = 0;
// while (names.hasMoreElements())
// arr[index++] = names.nextElement();
// return arr;
// }
//
// public void setAttribute(String name, Object value) {
// getHttpAttributes().put(name, value);
// }
//
// public void putValue(String name, Object value) {
// setAttribute(name, value);
// }
//
// public void removeAttribute(String name) {
// getHttpAttributes().remove(name);
// getHttpParams().remove(name);
// }
//
// public void removeValue(String name) {
// removeAttribute(name);
// }
//
// public void invalidate() {
// getHttpAttributes().clear();
// }
//
// public boolean isNew() {
// return true;
// }
//
// public abstract String getRequestId();
//
// public abstract Map<String, Object> getHttpAttributes();
//
// public abstract Map<String, String> getHttpParams();
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/ModelController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.HttpSession;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class ModelController {
| @RequestMapping(value = "/model/featureSettingEnum.json", method = RequestMethod.GET) |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/ModelController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpSession.java
// public abstract class HttpSession {
//
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private long creationTime = System.currentTimeMillis();
//
// public HttpSession() {
//
// }
//
// public String getId() {
// return getRequestId();
// }
//
// public long getCreationTime() {
// return creationTime;
// }
//
// public long getLastAccessedTime() {
// // TODO : this time will updated by long connection
// //
// return creationTime;
// }
//
// public int getMaxInactiveInterval() {
// throw new NotImplementedException();
// }
//
// public void setMaxInactiveInterval(int interval) {
// throw new NotImplementedException();
// }
//
// public Object getAttribute(String name) {
// Object value;
// if ((value = getHttpParams().get(name)) != null)
// return value;
// if ((value = getHttpAttributes().get(name)) != null)
// return value;
// return null;
// }
//
// public Object getValue(String name) {
// return getAttribute(name);
// }
//
// public Enumeration<String> getAttributeNames() {
// return new Enumeration<String>() {
// Iterator<String> firest = getHttpParams().keySet().iterator();
// Iterator<String> second = getHttpAttributes().keySet().iterator();
//
// @Override
// public boolean hasMoreElements() {
// return firest.hasNext() || second.hasNext();
// }
//
// @Override
// public String nextElement() {
// try {
// return firest.next();
// } catch (NoSuchElementException e) {
// return second.next();
// }
// }
// };
// }
//
// public String[] getValueNames() {
// String[] arr = new String[getHttpParams().keySet().size() + getHttpAttributes().keySet().size()];
// Enumeration<String> names = getAttributeNames();
// int index = 0;
// while (names.hasMoreElements())
// arr[index++] = names.nextElement();
// return arr;
// }
//
// public void setAttribute(String name, Object value) {
// getHttpAttributes().put(name, value);
// }
//
// public void putValue(String name, Object value) {
// setAttribute(name, value);
// }
//
// public void removeAttribute(String name) {
// getHttpAttributes().remove(name);
// getHttpParams().remove(name);
// }
//
// public void removeValue(String name) {
// removeAttribute(name);
// }
//
// public void invalidate() {
// getHttpAttributes().clear();
// }
//
// public boolean isNew() {
// return true;
// }
//
// public abstract String getRequestId();
//
// public abstract Map<String, Object> getHttpAttributes();
//
// public abstract Map<String, String> getHttpParams();
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.HttpSession;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class ModelController {
@RequestMapping(value = "/model/featureSettingEnum.json", method = RequestMethod.GET)
public
@ResponseBody
ApiResult<Void> featureSettingEnumGet(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "modelId", required = false) Long modelId,
@RequestParam(value = "featureId", required = false) Long featureId) {
System.out.println(String.format("featureSettingEnumGet %d ", modelId));
return new ApiResult<Void>();
}
@RequestMapping(value = "/model/featureSettingEnum.json", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public
@ResponseBody
ApiResult<Boolean> featureSettingEnumPost(
@RequestParam(value = "projectId", required = false) Long projectId, | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpSession.java
// public abstract class HttpSession {
//
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private long creationTime = System.currentTimeMillis();
//
// public HttpSession() {
//
// }
//
// public String getId() {
// return getRequestId();
// }
//
// public long getCreationTime() {
// return creationTime;
// }
//
// public long getLastAccessedTime() {
// // TODO : this time will updated by long connection
// //
// return creationTime;
// }
//
// public int getMaxInactiveInterval() {
// throw new NotImplementedException();
// }
//
// public void setMaxInactiveInterval(int interval) {
// throw new NotImplementedException();
// }
//
// public Object getAttribute(String name) {
// Object value;
// if ((value = getHttpParams().get(name)) != null)
// return value;
// if ((value = getHttpAttributes().get(name)) != null)
// return value;
// return null;
// }
//
// public Object getValue(String name) {
// return getAttribute(name);
// }
//
// public Enumeration<String> getAttributeNames() {
// return new Enumeration<String>() {
// Iterator<String> firest = getHttpParams().keySet().iterator();
// Iterator<String> second = getHttpAttributes().keySet().iterator();
//
// @Override
// public boolean hasMoreElements() {
// return firest.hasNext() || second.hasNext();
// }
//
// @Override
// public String nextElement() {
// try {
// return firest.next();
// } catch (NoSuchElementException e) {
// return second.next();
// }
// }
// };
// }
//
// public String[] getValueNames() {
// String[] arr = new String[getHttpParams().keySet().size() + getHttpAttributes().keySet().size()];
// Enumeration<String> names = getAttributeNames();
// int index = 0;
// while (names.hasMoreElements())
// arr[index++] = names.nextElement();
// return arr;
// }
//
// public void setAttribute(String name, Object value) {
// getHttpAttributes().put(name, value);
// }
//
// public void putValue(String name, Object value) {
// setAttribute(name, value);
// }
//
// public void removeAttribute(String name) {
// getHttpAttributes().remove(name);
// getHttpParams().remove(name);
// }
//
// public void removeValue(String name) {
// removeAttribute(name);
// }
//
// public void invalidate() {
// getHttpAttributes().clear();
// }
//
// public boolean isNew() {
// return true;
// }
//
// public abstract String getRequestId();
//
// public abstract Map<String, Object> getHttpAttributes();
//
// public abstract Map<String, String> getHttpParams();
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/ModelController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.HttpSession;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class ModelController {
@RequestMapping(value = "/model/featureSettingEnum.json", method = RequestMethod.GET)
public
@ResponseBody
ApiResult<Void> featureSettingEnumGet(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "modelId", required = false) Long modelId,
@RequestParam(value = "featureId", required = false) Long featureId) {
System.out.println(String.format("featureSettingEnumGet %d ", modelId));
return new ApiResult<Void>();
}
@RequestMapping(value = "/model/featureSettingEnum.json", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public
@ResponseBody
ApiResult<Boolean> featureSettingEnumPost(
@RequestParam(value = "projectId", required = false) Long projectId, | @RequestBody ProjectModel featureSettingEnumVo) { |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/ModelController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpSession.java
// public abstract class HttpSession {
//
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private long creationTime = System.currentTimeMillis();
//
// public HttpSession() {
//
// }
//
// public String getId() {
// return getRequestId();
// }
//
// public long getCreationTime() {
// return creationTime;
// }
//
// public long getLastAccessedTime() {
// // TODO : this time will updated by long connection
// //
// return creationTime;
// }
//
// public int getMaxInactiveInterval() {
// throw new NotImplementedException();
// }
//
// public void setMaxInactiveInterval(int interval) {
// throw new NotImplementedException();
// }
//
// public Object getAttribute(String name) {
// Object value;
// if ((value = getHttpParams().get(name)) != null)
// return value;
// if ((value = getHttpAttributes().get(name)) != null)
// return value;
// return null;
// }
//
// public Object getValue(String name) {
// return getAttribute(name);
// }
//
// public Enumeration<String> getAttributeNames() {
// return new Enumeration<String>() {
// Iterator<String> firest = getHttpParams().keySet().iterator();
// Iterator<String> second = getHttpAttributes().keySet().iterator();
//
// @Override
// public boolean hasMoreElements() {
// return firest.hasNext() || second.hasNext();
// }
//
// @Override
// public String nextElement() {
// try {
// return firest.next();
// } catch (NoSuchElementException e) {
// return second.next();
// }
// }
// };
// }
//
// public String[] getValueNames() {
// String[] arr = new String[getHttpParams().keySet().size() + getHttpAttributes().keySet().size()];
// Enumeration<String> names = getAttributeNames();
// int index = 0;
// while (names.hasMoreElements())
// arr[index++] = names.nextElement();
// return arr;
// }
//
// public void setAttribute(String name, Object value) {
// getHttpAttributes().put(name, value);
// }
//
// public void putValue(String name, Object value) {
// setAttribute(name, value);
// }
//
// public void removeAttribute(String name) {
// getHttpAttributes().remove(name);
// getHttpParams().remove(name);
// }
//
// public void removeValue(String name) {
// removeAttribute(name);
// }
//
// public void invalidate() {
// getHttpAttributes().clear();
// }
//
// public boolean isNew() {
// return true;
// }
//
// public abstract String getRequestId();
//
// public abstract Map<String, Object> getHttpAttributes();
//
// public abstract Map<String, String> getHttpParams();
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.HttpSession;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import java.util.List; | }
@RequestMapping(value = "/model/featureAnalysis.json", method = RequestMethod.GET)
public
@ResponseBody
ApiResult<Void> getModelFeatureAnalysis(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "modelId", required = false) Long modelId,
@RequestParam(value = "featureId", required = false) Long featureId) {
System.out.println(String.format("getModelFeatureAnalysist %d ", featureId));
return new ApiResult<Void>();
}
@RequestMapping(value = "/model/clone.json", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public
@ResponseBody
ApiResult<Long> clone(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestBody ProjectModel cloneModelVo) {
System.out.println(String.format("getModelFeatureAnalysist %d ", projectId));
return new ApiResult<Long>();
}
@RequestMapping(value = "/model/rename.json", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public
@ResponseBody
ApiResult<Boolean> rename(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "modelId", required = false) Long modelId,
@RequestParam(value = "modelName", required = false) String modelName, | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpSession.java
// public abstract class HttpSession {
//
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private long creationTime = System.currentTimeMillis();
//
// public HttpSession() {
//
// }
//
// public String getId() {
// return getRequestId();
// }
//
// public long getCreationTime() {
// return creationTime;
// }
//
// public long getLastAccessedTime() {
// // TODO : this time will updated by long connection
// //
// return creationTime;
// }
//
// public int getMaxInactiveInterval() {
// throw new NotImplementedException();
// }
//
// public void setMaxInactiveInterval(int interval) {
// throw new NotImplementedException();
// }
//
// public Object getAttribute(String name) {
// Object value;
// if ((value = getHttpParams().get(name)) != null)
// return value;
// if ((value = getHttpAttributes().get(name)) != null)
// return value;
// return null;
// }
//
// public Object getValue(String name) {
// return getAttribute(name);
// }
//
// public Enumeration<String> getAttributeNames() {
// return new Enumeration<String>() {
// Iterator<String> firest = getHttpParams().keySet().iterator();
// Iterator<String> second = getHttpAttributes().keySet().iterator();
//
// @Override
// public boolean hasMoreElements() {
// return firest.hasNext() || second.hasNext();
// }
//
// @Override
// public String nextElement() {
// try {
// return firest.next();
// } catch (NoSuchElementException e) {
// return second.next();
// }
// }
// };
// }
//
// public String[] getValueNames() {
// String[] arr = new String[getHttpParams().keySet().size() + getHttpAttributes().keySet().size()];
// Enumeration<String> names = getAttributeNames();
// int index = 0;
// while (names.hasMoreElements())
// arr[index++] = names.nextElement();
// return arr;
// }
//
// public void setAttribute(String name, Object value) {
// getHttpAttributes().put(name, value);
// }
//
// public void putValue(String name, Object value) {
// setAttribute(name, value);
// }
//
// public void removeAttribute(String name) {
// getHttpAttributes().remove(name);
// getHttpParams().remove(name);
// }
//
// public void removeValue(String name) {
// removeAttribute(name);
// }
//
// public void invalidate() {
// getHttpAttributes().clear();
// }
//
// public boolean isNew() {
// return true;
// }
//
// public abstract String getRequestId();
//
// public abstract Map<String, Object> getHttpAttributes();
//
// public abstract Map<String, String> getHttpParams();
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/ModelController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.HttpSession;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import java.util.List;
}
@RequestMapping(value = "/model/featureAnalysis.json", method = RequestMethod.GET)
public
@ResponseBody
ApiResult<Void> getModelFeatureAnalysis(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "modelId", required = false) Long modelId,
@RequestParam(value = "featureId", required = false) Long featureId) {
System.out.println(String.format("getModelFeatureAnalysist %d ", featureId));
return new ApiResult<Void>();
}
@RequestMapping(value = "/model/clone.json", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public
@ResponseBody
ApiResult<Long> clone(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestBody ProjectModel cloneModelVo) {
System.out.println(String.format("getModelFeatureAnalysist %d ", projectId));
return new ApiResult<Long>();
}
@RequestMapping(value = "/model/rename.json", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public
@ResponseBody
ApiResult<Boolean> rename(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "modelId", required = false) Long modelId,
@RequestParam(value = "modelName", required = false) String modelName, | HttpSession httpSession) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/HttpContext.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
// public interface HttpRequestVisitor {
// String visitRemoteAddress();
//
// String visitURI();
//
// String[] visitTerms();
//
// RequestMethod visitHttpMethod();
//
// String visitHttpBody();
//
// Map<String, String> visitHttpParams();
//
// Map<String, String> visitHttpHeaders();
//
// HttpVersion visitHttpVersion();
// }
| import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.request.HttpRequestVisitor;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong; | package org.nesty.core.server.rest;
/**
* http context. include all http request and response information
*
* Author Michael on 03/03/2016.
*/
public class HttpContext extends HttpSession {
private static String NestyUID = UUID.randomUUID().toString();
private static AtomicLong SequenceId = new AtomicLong(0);
// raw body
protected String httpBody;
// params include query string and body param
protected Map<String, String> httpParams;
// attribute map values
protected Map<String, Object> httpAttributes;
// header values
protected Map<String, String> httpHeaders;
// client request with unique id, fetch it from http header(Request-Id)
// if exsit. or generate by UUID
private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// ip address from origin client, fetch it from getRemoteAddr()
// or header X-FORWARDED-FOR
private String remoteAddress;
// raw uri exclude query string
private String uri;
// http uri terms split by "/"
private String[] terms;
// Http request method. NOT null | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
// public interface HttpRequestVisitor {
// String visitRemoteAddress();
//
// String visitURI();
//
// String[] visitTerms();
//
// RequestMethod visitHttpMethod();
//
// String visitHttpBody();
//
// Map<String, String> visitHttpParams();
//
// Map<String, String> visitHttpHeaders();
//
// HttpVersion visitHttpVersion();
// }
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.request.HttpRequestVisitor;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
package org.nesty.core.server.rest;
/**
* http context. include all http request and response information
*
* Author Michael on 03/03/2016.
*/
public class HttpContext extends HttpSession {
private static String NestyUID = UUID.randomUUID().toString();
private static AtomicLong SequenceId = new AtomicLong(0);
// raw body
protected String httpBody;
// params include query string and body param
protected Map<String, String> httpParams;
// attribute map values
protected Map<String, Object> httpAttributes;
// header values
protected Map<String, String> httpHeaders;
// client request with unique id, fetch it from http header(Request-Id)
// if exsit. or generate by UUID
private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// ip address from origin client, fetch it from getRemoteAddr()
// or header X-FORWARDED-FOR
private String remoteAddress;
// raw uri exclude query string
private String uri;
// http uri terms split by "/"
private String[] terms;
// Http request method. NOT null | private RequestMethod requestMethod; |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/HttpContext.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
// public interface HttpRequestVisitor {
// String visitRemoteAddress();
//
// String visitURI();
//
// String[] visitTerms();
//
// RequestMethod visitHttpMethod();
//
// String visitHttpBody();
//
// Map<String, String> visitHttpParams();
//
// Map<String, String> visitHttpHeaders();
//
// HttpVersion visitHttpVersion();
// }
| import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.request.HttpRequestVisitor;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong; | package org.nesty.core.server.rest;
/**
* http context. include all http request and response information
*
* Author Michael on 03/03/2016.
*/
public class HttpContext extends HttpSession {
private static String NestyUID = UUID.randomUUID().toString();
private static AtomicLong SequenceId = new AtomicLong(0);
// raw body
protected String httpBody;
// params include query string and body param
protected Map<String, String> httpParams;
// attribute map values
protected Map<String, Object> httpAttributes;
// header values
protected Map<String, String> httpHeaders;
// client request with unique id, fetch it from http header(Request-Id)
// if exsit. or generate by UUID
private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// ip address from origin client, fetch it from getRemoteAddr()
// or header X-FORWARDED-FOR
private String remoteAddress;
// raw uri exclude query string
private String uri;
// http uri terms split by "/"
private String[] terms;
// Http request method. NOT null
private RequestMethod requestMethod;
// Http long connection
private boolean isKeepAlive = true;
private HttpContext() {
}
| // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
// public interface HttpRequestVisitor {
// String visitRemoteAddress();
//
// String visitURI();
//
// String[] visitTerms();
//
// RequestMethod visitHttpMethod();
//
// String visitHttpBody();
//
// Map<String, String> visitHttpParams();
//
// Map<String, String> visitHttpHeaders();
//
// HttpVersion visitHttpVersion();
// }
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.request.HttpRequestVisitor;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
package org.nesty.core.server.rest;
/**
* http context. include all http request and response information
*
* Author Michael on 03/03/2016.
*/
public class HttpContext extends HttpSession {
private static String NestyUID = UUID.randomUUID().toString();
private static AtomicLong SequenceId = new AtomicLong(0);
// raw body
protected String httpBody;
// params include query string and body param
protected Map<String, String> httpParams;
// attribute map values
protected Map<String, Object> httpAttributes;
// header values
protected Map<String, String> httpHeaders;
// client request with unique id, fetch it from http header(Request-Id)
// if exsit. or generate by UUID
private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// ip address from origin client, fetch it from getRemoteAddr()
// or header X-FORWARDED-FOR
private String remoteAddress;
// raw uri exclude query string
private String uri;
// http uri terms split by "/"
private String[] terms;
// Http request method. NOT null
private RequestMethod requestMethod;
// Http long connection
private boolean isKeepAlive = true;
private HttpContext() {
}
| public static HttpContext build(HttpRequestVisitor visitor) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/HttpContext.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
// public interface HttpRequestVisitor {
// String visitRemoteAddress();
//
// String visitURI();
//
// String[] visitTerms();
//
// RequestMethod visitHttpMethod();
//
// String visitHttpBody();
//
// Map<String, String> visitHttpParams();
//
// Map<String, String> visitHttpHeaders();
//
// HttpVersion visitHttpVersion();
// }
| import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.request.HttpRequestVisitor;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong; | package org.nesty.core.server.rest;
/**
* http context. include all http request and response information
*
* Author Michael on 03/03/2016.
*/
public class HttpContext extends HttpSession {
private static String NestyUID = UUID.randomUUID().toString();
private static AtomicLong SequenceId = new AtomicLong(0);
// raw body
protected String httpBody;
// params include query string and body param
protected Map<String, String> httpParams;
// attribute map values
protected Map<String, Object> httpAttributes;
// header values
protected Map<String, String> httpHeaders;
// client request with unique id, fetch it from http header(Request-Id)
// if exsit. or generate by UUID
private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// ip address from origin client, fetch it from getRemoteAddr()
// or header X-FORWARDED-FOR
private String remoteAddress;
// raw uri exclude query string
private String uri;
// http uri terms split by "/"
private String[] terms;
// Http request method. NOT null
private RequestMethod requestMethod;
// Http long connection
private boolean isKeepAlive = true;
private HttpContext() {
}
public static HttpContext build(HttpRequestVisitor visitor) {
HttpContext context = new HttpContext();
context.remoteAddress = visitor.visitRemoteAddress();
context.uri = visitor.visitURI();
context.terms = visitor.visitTerms();
context.requestMethod = visitor.visitHttpMethod();
context.httpHeaders = visitor.visitHttpHeaders();
context.httpParams = visitor.visitHttpParams();
// TODO : if exclude GET or not ?
//
context.httpBody = visitor.visitHttpBody();
if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 && | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/request/HttpRequestVisitor.java
// public interface HttpRequestVisitor {
// String visitRemoteAddress();
//
// String visitURI();
//
// String[] visitTerms();
//
// RequestMethod visitHttpMethod();
//
// String visitHttpBody();
//
// Map<String, String> visitHttpParams();
//
// Map<String, String> visitHttpHeaders();
//
// HttpVersion visitHttpVersion();
// }
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
import io.netty.handler.codec.http.HttpVersion;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.rest.request.HttpRequestVisitor;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
package org.nesty.core.server.rest;
/**
* http context. include all http request and response information
*
* Author Michael on 03/03/2016.
*/
public class HttpContext extends HttpSession {
private static String NestyUID = UUID.randomUUID().toString();
private static AtomicLong SequenceId = new AtomicLong(0);
// raw body
protected String httpBody;
// params include query string and body param
protected Map<String, String> httpParams;
// attribute map values
protected Map<String, Object> httpAttributes;
// header values
protected Map<String, String> httpHeaders;
// client request with unique id, fetch it from http header(Request-Id)
// if exsit. or generate by UUID
private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// ip address from origin client, fetch it from getRemoteAddr()
// or header X-FORWARDED-FOR
private String remoteAddress;
// raw uri exclude query string
private String uri;
// http uri terms split by "/"
private String[] terms;
// Http request method. NOT null
private RequestMethod requestMethod;
// Http long connection
private boolean isKeepAlive = true;
private HttpContext() {
}
public static HttpContext build(HttpRequestVisitor visitor) {
HttpContext context = new HttpContext();
context.remoteAddress = visitor.visitRemoteAddress();
context.uri = visitor.visitURI();
context.terms = visitor.visitTerms();
context.requestMethod = visitor.visitHttpMethod();
context.httpHeaders = visitor.visitHttpHeaders();
context.httpParams = visitor.visitHttpParams();
// TODO : if exclude GET or not ?
//
context.httpBody = visitor.visitHttpBody();
if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 && | HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION))) |
gugemichael/nesty | example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type; | package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1 | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
// Path: example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type;
package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1 | @RequestMapping(value = "/", method = RequestMethod.POST) |
gugemichael/nesty | example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type; | package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1
@RequestMapping(value = "/", method = RequestMethod.POST) | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
// Path: example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type;
package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1
@RequestMapping(value = "/", method = RequestMethod.POST) | public ServiceResponse createProject(@RequestParam(value = "not-exist", required = false) int nouse, @RequestBody ProjectModel project) { |
gugemichael/nesty | example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type; | package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1
@RequestMapping(value = "/", method = RequestMethod.POST) | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
// Path: example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type;
package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1
@RequestMapping(value = "/", method = RequestMethod.POST) | public ServiceResponse createProject(@RequestParam(value = "not-exist", required = false) int nouse, @RequestBody ProjectModel project) { |
gugemichael/nesty | example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type; | package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1
@RequestMapping(value = "/", method = RequestMethod.POST)
public ServiceResponse createProject(@RequestParam(value = "not-exist", required = false) int nouse, @RequestBody ProjectModel project) {
System.out.println("createProject() projectName " + project.getProjectName() + " nouse " + nouse);
return new ServiceResponse();
}
// [GET] http://host:port/projects/1
@RequestMapping("/type/{type}") | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/Type.java
// public enum Type {
// A, B, C
// }
// Path: example/src/main/java/org/nesty/example/httpserver/handler/ServiceController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import org.nesty.example.httpserver.handler.model.Type;
package org.nesty.example.httpserver.handler;
@Controller
@RequestMapping("/projects")
public class ServiceController {
// [POST] http://host:port/projects/1
@RequestMapping(value = "/", method = RequestMethod.POST)
public ServiceResponse createProject(@RequestParam(value = "not-exist", required = false) int nouse, @RequestBody ProjectModel project) {
System.out.println("createProject() projectName " + project.getProjectName() + " nouse " + nouse);
return new ServiceResponse();
}
// [GET] http://host:port/projects/1
@RequestMapping("/type/{type}") | public ServiceResponse getProjectByType(@PathVariable("type") Type type) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/interceptor/Interceptor.java | // Path: core/src/main/java/org/nesty/core/server/NestyOptionProvider.java
// public class NestyOptionProvider {
//
// private Map<NestyOptions<?>, Object> options = new ConcurrentHashMap<>();
//
// public <T> NestyOptionProvider option(NestyOptions<T> option, T value) {
// this.options.put(option, value);
// return this;
// }
//
// /**
// * return specified option name's value if this option is setted. or named option
// * default value.
// *
// * @param option named option already defined
// * @return setted value or default value
// */
// @SuppressWarnings("unchecked")
// public <T> T option(NestyOptions<T> option) {
// T value;
// if ((value = (T) options.get(option)) != null)
// return value;
// else
// return option.defaultValue();
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
| import io.netty.handler.codec.http.DefaultFullHttpResponse;
import org.nesty.core.server.NestyOptionProvider;
import org.nesty.core.server.rest.HttpContext; | package org.nesty.core.server.rest.interceptor;
/**
* Filter of http request and response
*
* Author : Michael
* Date : March 09, 2016
*/
public abstract class Interceptor {
public boolean install(NestyOptionProvider nesty) {
return true;
}
public void destroy() {
}
/**
* http context of request information. user can update
* the value of context.
*
* @param context http context
* @return true if we continue the request or false will deny the request by http code 403
*/ | // Path: core/src/main/java/org/nesty/core/server/NestyOptionProvider.java
// public class NestyOptionProvider {
//
// private Map<NestyOptions<?>, Object> options = new ConcurrentHashMap<>();
//
// public <T> NestyOptionProvider option(NestyOptions<T> option, T value) {
// this.options.put(option, value);
// return this;
// }
//
// /**
// * return specified option name's value if this option is setted. or named option
// * default value.
// *
// * @param option named option already defined
// * @return setted value or default value
// */
// @SuppressWarnings("unchecked")
// public <T> T option(NestyOptions<T> option) {
// T value;
// if ((value = (T) options.get(option)) != null)
// return value;
// else
// return option.defaultValue();
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/interceptor/Interceptor.java
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import org.nesty.core.server.NestyOptionProvider;
import org.nesty.core.server.rest.HttpContext;
package org.nesty.core.server.rest.interceptor;
/**
* Filter of http request and response
*
* Author : Michael
* Date : March 09, 2016
*/
public abstract class Interceptor {
public boolean install(NestyOptionProvider nesty) {
return true;
}
public void destroy() {
}
/**
* http context of request information. user can update
* the value of context.
*
* @param context http context
* @return true if we continue the request or false will deny the request by http code 403
*/ | public boolean filter(final HttpContext context) { |
gugemichael/nesty | commons/src/main/java/org/nesty/commons/utils/SerializeUtils.java | // Path: commons/src/main/java/org/nesty/commons/exception/SerializeException.java
// public class SerializeException extends Exception {
//
// public SerializeException(String msg) {
// super(msg);
// }
// }
| import com.google.common.base.Charsets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import org.nesty.commons.exception.SerializeException;
import java.nio.charset.Charset; | package org.nesty.commons.utils;
/**
* [Author] Michael
* [Date] March 04, 2016
*/
public class SerializeUtils {
private static final Charset CHARSET = Charsets.UTF_8;
private static final Gson GSON = new GsonBuilder().create();
public static byte[] encode(Object stuff) {
return GSON.toJson(stuff).getBytes(CHARSET);
}
| // Path: commons/src/main/java/org/nesty/commons/exception/SerializeException.java
// public class SerializeException extends Exception {
//
// public SerializeException(String msg) {
// super(msg);
// }
// }
// Path: commons/src/main/java/org/nesty/commons/utils/SerializeUtils.java
import com.google.common.base.Charsets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import org.nesty.commons.exception.SerializeException;
import java.nio.charset.Charset;
package org.nesty.commons.utils;
/**
* [Author] Michael
* [Date] March 04, 2016
*/
public class SerializeUtils {
private static final Charset CHARSET = Charsets.UTF_8;
private static final Gson GSON = new GsonBuilder().create();
public static byte[] encode(Object stuff) {
return GSON.toJson(stuff).getBytes(CHARSET);
}
| public static Object decode(String stuff, Class<?> clazz) throws SerializeException { |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/CalculateTaskController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse; | package com.nesty.test.neptune;
@Controller
@RequestMapping("/web/api")
public class CalculateTaskController {
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/CalculateTaskController.java
import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
package com.nesty.test.neptune;
@Controller
@RequestMapping("/web/api")
public class CalculateTaskController {
| @RequestMapping(value = "/task/calculate.json", method = RequestMethod.POST) |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/CalculateTaskController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse; | package com.nesty.test.neptune;
@Controller
@RequestMapping("/web/api")
public class CalculateTaskController {
@RequestMapping(value = "/task/calculate.json", method = RequestMethod.POST) | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/CalculateTaskController.java
import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
package com.nesty.test.neptune;
@Controller
@RequestMapping("/web/api")
public class CalculateTaskController {
@RequestMapping(value = "/task/calculate.json", method = RequestMethod.POST) | public ServiceResponse calculateTask( |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/FeatureController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class FeatureController { | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/FeatureController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class FeatureController { | @RequestMapping(value = "/feature/rename.json", method = RequestMethod.POST) |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/FeatureController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class FeatureController {
@RequestMapping(value = "/feature/rename.json", method = RequestMethod.POST) | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/FeatureController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class FeatureController {
@RequestMapping(value = "/feature/rename.json", method = RequestMethod.POST) | public ServiceResponse rename( |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/neptune/FeatureController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List; | package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class FeatureController {
@RequestMapping(value = "/feature/rename.json", method = RequestMethod.POST)
public ServiceResponse rename(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "featureId", required = false) Long featureId,
@RequestParam(value = "featureName", required = false) String featureName) {
System.out.println(String.format("rename %d %d %s", projectId, featureId, featureName));
return new ServiceResponse();
}
@RequestMapping(value = "/feature/getFeatureTree.json", method = RequestMethod.GET)
public ServiceResponse getFeatureTree(
@RequestParam(value = "projectId", required = false) Long projectId) {
System.out.println(String.format("getFeatureTreek %d ", projectId));
return new ServiceResponse();
}
@RequestMapping(value = "/feature/createFeature.json", method = RequestMethod.POST)
public ServiceResponse createFeature(
@RequestParam(value = "projectId", required = false) Long projectId, | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ProjectModel.java
// @Controller
// public class ProjectModel {
//
// private Integer projectId;
// private String projectName;
// private String projectOwener;
//
// public Integer getProjectId() {
// return projectId;
// }
//
// public String getProjectName() {
// return projectName;
// }
//
// public String getProjectOwener() {
// return projectOwener;
// }
// }
//
// Path: example/src/main/java/org/nesty/example/httpserver/handler/model/ServiceResponse.java
// public class ServiceResponse {
//
// private int errorCode = 0;
// private String errorMsg = "success";
// }
// Path: example/src/main/java/com/com/nesty/test/neptune/FeatureController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.example.httpserver.handler.model.ProjectModel;
import org.nesty.example.httpserver.handler.model.ServiceResponse;
import java.util.List;
package com.nesty.test.neptune;
@RequestMapping("/web/api")
@Controller
public class FeatureController {
@RequestMapping(value = "/feature/rename.json", method = RequestMethod.POST)
public ServiceResponse rename(
@RequestParam(value = "projectId", required = false) Long projectId,
@RequestParam(value = "featureId", required = false) Long featureId,
@RequestParam(value = "featureName", required = false) String featureName) {
System.out.println(String.format("rename %d %d %s", projectId, featureId, featureName));
return new ServiceResponse();
}
@RequestMapping(value = "/feature/getFeatureTree.json", method = RequestMethod.GET)
public ServiceResponse getFeatureTree(
@RequestParam(value = "projectId", required = false) Long projectId) {
System.out.println(String.format("getFeatureTreek %d ", projectId));
return new ServiceResponse();
}
@RequestMapping(value = "/feature/createFeature.json", method = RequestMethod.POST)
public ServiceResponse createFeature(
@RequestParam(value = "projectId", required = false) Long projectId, | @RequestBody(required = false) ProjectModel createFeatureVo) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/request/NettyHttpRequestVisitor.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
| import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public class NettyHttpRequestVisitor implements HttpRequestVisitor {
private final Channel channel;
private final FullHttpRequest request;
public NettyHttpRequestVisitor(Channel channel, FullHttpRequest request) {
this.channel = channel;
this.request = request;
}
@Override
public String visitRemoteAddress() {
for (Map.Entry<String, String> entry : request.headers()) { | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/request/NettyHttpRequestVisitor.java
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public class NettyHttpRequestVisitor implements HttpRequestVisitor {
private final Channel channel;
private final FullHttpRequest request;
public NettyHttpRequestVisitor(Channel channel, FullHttpRequest request) {
this.channel = channel;
this.request = request;
}
@Override
public String visitRemoteAddress() {
for (Map.Entry<String, String> entry : request.headers()) { | if (entry.getKey().equals(HttpConstants.HEADER_X_FORWARDED_FOR)) |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/request/NettyHttpRequestVisitor.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
| import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public class NettyHttpRequestVisitor implements HttpRequestVisitor {
private final Channel channel;
private final FullHttpRequest request;
public NettyHttpRequestVisitor(Channel channel, FullHttpRequest request) {
this.channel = channel;
this.request = request;
}
@Override
public String visitRemoteAddress() {
for (Map.Entry<String, String> entry : request.headers()) {
if (entry.getKey().equals(HttpConstants.HEADER_X_FORWARDED_FOR))
return entry.getValue();
}
return ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress();
}
@Override | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/request/NettyHttpRequestVisitor.java
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public class NettyHttpRequestVisitor implements HttpRequestVisitor {
private final Channel channel;
private final FullHttpRequest request;
public NettyHttpRequestVisitor(Channel channel, FullHttpRequest request) {
this.channel = channel;
this.request = request;
}
@Override
public String visitRemoteAddress() {
for (Map.Entry<String, String> entry : request.headers()) {
if (entry.getKey().equals(HttpConstants.HEADER_X_FORWARDED_FOR))
return entry.getValue();
}
return ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress();
}
@Override | public RequestMethod visitHttpMethod() { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/rest/request/NettyHttpRequestVisitor.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
| import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public class NettyHttpRequestVisitor implements HttpRequestVisitor {
private final Channel channel;
private final FullHttpRequest request;
public NettyHttpRequestVisitor(Channel channel, FullHttpRequest request) {
this.channel = channel;
this.request = request;
}
@Override
public String visitRemoteAddress() {
for (Map.Entry<String, String> entry : request.headers()) {
if (entry.getKey().equals(HttpConstants.HEADER_X_FORWARDED_FOR))
return entry.getValue();
}
return ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress();
}
@Override
public RequestMethod visitHttpMethod() { | // Path: commons/src/main/java/org/nesty/commons/constant/http/HttpConstants.java
// public class HttpConstants {
//
// public static final String HEADER_X_FORWARDED_FOR = "X-Forwarded-For";
// public static final String HEADER_CONTENT_LENGTH = "Content-Length";
// public static final String HEADER_CONTENT_TYPE = "Content-Type";
// public static final String HEADER_CONNECTION = "Connection";
//
// public static final String HEADER_SERVER = "Server";
// public static final String HEADER_REQUEST_ID = "Request-Id";
// public static final String HEADER_CONNECTION_KEEPALIVE = "keep-alive";
// public static final String HEADER_CONNECTION_CLOSE = "close";
// public static final String HEADER_CONTENT_TYPE_TEXT = "application/text";
// public static final String HEADER_CONTENT_TYPE_JSON = "application/json";
// }
//
// Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
//
// Path: core/src/main/java/org/nesty/core/server/utils/HttpUtils.java
// public class HttpUtils {
//
// public static RequestMethod convertHttpMethodFromNetty(FullHttpRequest request) {
// try {
// return RequestMethod.valueOf(request.getMethod().name().toUpperCase());
// } catch (IllegalArgumentException | NullPointerException e) {
// return RequestMethod.UNKOWN;
// }
// }
//
// public static String truncateUrl(String url) {
// if (url.contains("?"))
// url = url.substring(0, url.indexOf("?"));
// return url;
// }
// }
// Path: core/src/main/java/org/nesty/core/server/rest/request/NettyHttpRequestVisitor.java
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
import org.nesty.commons.constant.http.HttpConstants;
import org.nesty.commons.constant.http.RequestMethod;
import org.nesty.core.server.utils.HttpUtils;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package org.nesty.core.server.rest.request;
/**
* nesty
*
* Author Michael on 03/03/2016.
*/
public class NettyHttpRequestVisitor implements HttpRequestVisitor {
private final Channel channel;
private final FullHttpRequest request;
public NettyHttpRequestVisitor(Channel channel, FullHttpRequest request) {
this.channel = channel;
this.request = request;
}
@Override
public String visitRemoteAddress() {
for (Map.Entry<String, String> entry : request.headers()) {
if (entry.getKey().equals(HttpConstants.HEADER_X_FORWARDED_FOR))
return entry.getValue();
}
return ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress();
}
@Override
public RequestMethod visitHttpMethod() { | return HttpUtils.convertHttpMethodFromNetty(request); |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/billing/BindController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
| import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.annotations.ResponseBody;
import org.nesty.commons.constant.http.RequestMethod; | package com.nesty.test.billing;
@Controller
public class BindController {
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
// Path: example/src/main/java/com/com/nesty/test/billing/BindController.java
import org.nesty.commons.annotations.Controller;
import org.nesty.commons.annotations.RequestMapping;
import org.nesty.commons.annotations.RequestParam;
import org.nesty.commons.annotations.ResponseBody;
import org.nesty.commons.constant.http.RequestMethod;
package com.nesty.test.billing;
@Controller
public class BindController {
| @RequestMapping(value = "/rds/bind", method = RequestMethod.POST) |
gugemichael/nesty | example/src/main/java/com/com/nesty/test/billing/ContractController.java | // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
| import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import java.util.List; | package com.nesty.test.billing;
@Controller
public class ContractController {
| // Path: commons/src/main/java/org/nesty/commons/constant/http/RequestMethod.java
// public enum RequestMethod {
// GET, POST, PUT, DELETE, UNKOWN
// }
// Path: example/src/main/java/com/com/nesty/test/billing/ContractController.java
import org.nesty.commons.annotations.*;
import org.nesty.commons.constant.http.RequestMethod;
import java.util.List;
package com.nesty.test.billing;
@Controller
public class ContractController {
| @RequestMapping(value = "/contract/new", method = RequestMethod.POST) |
gugemichael/nesty | example/src/main/java/org/nesty/example/httpserver/handler/ServiceQPSInterceptor.java | // Path: core/src/main/java/org/nesty/core/server/NestyOptionProvider.java
// public class NestyOptionProvider {
//
// private Map<NestyOptions<?>, Object> options = new ConcurrentHashMap<>();
//
// public <T> NestyOptionProvider option(NestyOptions<T> option, T value) {
// this.options.put(option, value);
// return this;
// }
//
// /**
// * return specified option name's value if this option is setted. or named option
// * default value.
// *
// * @param option named option already defined
// * @return setted value or default value
// */
// @SuppressWarnings("unchecked")
// public <T> T option(NestyOptions<T> option) {
// T value;
// if ((value = (T) options.get(option)) != null)
// return value;
// else
// return option.defaultValue();
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
| import io.netty.handler.codec.http.DefaultFullHttpResponse;
import org.nesty.commons.annotations.Interceptor;
import org.nesty.core.server.NestyOptionProvider;
import org.nesty.core.server.rest.HttpContext; | package org.nesty.example.httpserver.handler;
@Interceptor
public class ServiceQPSInterceptor extends org.nesty.core.server.rest.interceptor.Interceptor {
@Override | // Path: core/src/main/java/org/nesty/core/server/NestyOptionProvider.java
// public class NestyOptionProvider {
//
// private Map<NestyOptions<?>, Object> options = new ConcurrentHashMap<>();
//
// public <T> NestyOptionProvider option(NestyOptions<T> option, T value) {
// this.options.put(option, value);
// return this;
// }
//
// /**
// * return specified option name's value if this option is setted. or named option
// * default value.
// *
// * @param option named option already defined
// * @return setted value or default value
// */
// @SuppressWarnings("unchecked")
// public <T> T option(NestyOptions<T> option) {
// T value;
// if ((value = (T) options.get(option)) != null)
// return value;
// else
// return option.defaultValue();
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
// Path: example/src/main/java/org/nesty/example/httpserver/handler/ServiceQPSInterceptor.java
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import org.nesty.commons.annotations.Interceptor;
import org.nesty.core.server.NestyOptionProvider;
import org.nesty.core.server.rest.HttpContext;
package org.nesty.example.httpserver.handler;
@Interceptor
public class ServiceQPSInterceptor extends org.nesty.core.server.rest.interceptor.Interceptor {
@Override | public boolean install(NestyOptionProvider nesty) { |
gugemichael/nesty | example/src/main/java/org/nesty/example/httpserver/handler/ServiceQPSInterceptor.java | // Path: core/src/main/java/org/nesty/core/server/NestyOptionProvider.java
// public class NestyOptionProvider {
//
// private Map<NestyOptions<?>, Object> options = new ConcurrentHashMap<>();
//
// public <T> NestyOptionProvider option(NestyOptions<T> option, T value) {
// this.options.put(option, value);
// return this;
// }
//
// /**
// * return specified option name's value if this option is setted. or named option
// * default value.
// *
// * @param option named option already defined
// * @return setted value or default value
// */
// @SuppressWarnings("unchecked")
// public <T> T option(NestyOptions<T> option) {
// T value;
// if ((value = (T) options.get(option)) != null)
// return value;
// else
// return option.defaultValue();
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
| import io.netty.handler.codec.http.DefaultFullHttpResponse;
import org.nesty.commons.annotations.Interceptor;
import org.nesty.core.server.NestyOptionProvider;
import org.nesty.core.server.rest.HttpContext; | package org.nesty.example.httpserver.handler;
@Interceptor
public class ServiceQPSInterceptor extends org.nesty.core.server.rest.interceptor.Interceptor {
@Override
public boolean install(NestyOptionProvider nesty) {
return super.install(nesty);
}
@Override | // Path: core/src/main/java/org/nesty/core/server/NestyOptionProvider.java
// public class NestyOptionProvider {
//
// private Map<NestyOptions<?>, Object> options = new ConcurrentHashMap<>();
//
// public <T> NestyOptionProvider option(NestyOptions<T> option, T value) {
// this.options.put(option, value);
// return this;
// }
//
// /**
// * return specified option name's value if this option is setted. or named option
// * default value.
// *
// * @param option named option already defined
// * @return setted value or default value
// */
// @SuppressWarnings("unchecked")
// public <T> T option(NestyOptions<T> option) {
// T value;
// if ((value = (T) options.get(option)) != null)
// return value;
// else
// return option.defaultValue();
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/HttpContext.java
// public class HttpContext extends HttpSession {
// private static String NestyUID = UUID.randomUUID().toString();
// private static AtomicLong SequenceId = new AtomicLong(0);
//
// // raw body
// protected String httpBody;
// // params include query string and body param
// protected Map<String, String> httpParams;
// // attribute map values
// protected Map<String, Object> httpAttributes;
// // header values
// protected Map<String, String> httpHeaders;
// // client request with unique id, fetch it from http header(Request-Id)
// // if exsit. or generate by UUID
// private String requestId = String.format("%s-%d", NestyUID, SequenceId.incrementAndGet());
// // ip address from origin client, fetch it from getRemoteAddr()
// // or header X-FORWARDED-FOR
// private String remoteAddress;
// // raw uri exclude query string
// private String uri;
// // http uri terms split by "/"
// private String[] terms;
// // Http request method. NOT null
// private RequestMethod requestMethod;
// // Http long connection
// private boolean isKeepAlive = true;
//
// private HttpContext() {
// }
//
// public static HttpContext build(HttpRequestVisitor visitor) {
// HttpContext context = new HttpContext();
// context.remoteAddress = visitor.visitRemoteAddress();
// context.uri = visitor.visitURI();
// context.terms = visitor.visitTerms();
// context.requestMethod = visitor.visitHttpMethod();
// context.httpHeaders = visitor.visitHttpHeaders();
// context.httpParams = visitor.visitHttpParams();
//
// // TODO : if exclude GET or not ?
// //
// context.httpBody = visitor.visitHttpBody();
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
// HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
// !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
// context.isKeepAlive = false;
//
// return context;
// }
//
// public boolean isKeepAlive() {
// return isKeepAlive;
// }
//
// public String getRemoteAddress() {
// return remoteAddress;
// }
//
// public String getUri() {
// return uri;
// }
//
// public String[] getTerms() {
// return terms;
// }
//
// public RequestMethod getRequestMethod() {
// return requestMethod;
// }
//
// public String getHttpBody() {
// return httpBody;
// }
//
// @Override
// public Map<String, String> getHttpParams() {
// return httpParams;
// }
//
// public Map<String, String> getHttpHeaders() {
// return httpHeaders;
// }
//
// @Override
// public String getRequestId() {
// return requestId;
// }
//
// @Override
// public Map<String, Object> getHttpAttributes() {
// return httpAttributes;
// }
// }
// Path: example/src/main/java/org/nesty/example/httpserver/handler/ServiceQPSInterceptor.java
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import org.nesty.commons.annotations.Interceptor;
import org.nesty.core.server.NestyOptionProvider;
import org.nesty.core.server.rest.HttpContext;
package org.nesty.example.httpserver.handler;
@Interceptor
public class ServiceQPSInterceptor extends org.nesty.core.server.rest.interceptor.Interceptor {
@Override
public boolean install(NestyOptionProvider nesty) {
return super.install(nesty);
}
@Override | public boolean filter(HttpContext context) { |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/NestyServerMonitor.java | // Path: core/src/main/java/org/nesty/core/server/rest/URLResource.java
// public class URLResource {
//
// // variable flag
// public static final char VARIABLE = '{';
// // resource identifier
// private URLResourceIdentifier identifier;
//
// private URLResource() {
//
// }
//
// public static URLResource fromHttp(String url, RequestMethod requestMethod) {
// URLResource resource = new URLResource();
// resource.identifier = URLResourceIdentifier.analyse(url);
// resource.identifier.requestMethod = requestMethod;
// return resource;
// }
//
// public RequestMethod requestMethod() {
// return identifier.requestMethod;
// }
//
// public List<String> fragments() {
// return identifier.fragments;
// }
//
// @Override
// public String toString() {
// return identifier.toString();
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public boolean equals(Object other) {
// return !(other == null || !(other instanceof URLResource)) && identifier.equals(((URLResource) other).identifier);
// }
//
// /**
// * URLResource uniqu identifier member. used for URLResource
// * equals and hashcode id
// */
// static class URLResourceIdentifier {
// protected List<String> fragments = new ArrayList<>(64);
// protected RequestMethod requestMethod;
//
// public static URLResourceIdentifier analyse(String url) {
// url = HttpUtils.truncateUrl(url);
// URLResourceIdentifier identifier = new URLResourceIdentifier();
// for (String s : Splitter.on('/').trimResults().omitEmptyStrings().split(url))
// identifier.fragments.add(s);
// return identifier;
// }
//
// @Override
// public boolean equals(Object object) {
// if (object == null || !(object instanceof URLResourceIdentifier))
// return false;
// URLResourceIdentifier other = (URLResourceIdentifier) object;
// if (requestMethod != other.requestMethod)
// return false;
// // rest array is not nessary
// if (fragments.size() != other.fragments.size())
// return false;
// for (int i = 0; i != fragments.size(); i++) {
// if (!(fragments.get(i).charAt(0) == VARIABLE || other.fragments.get(i).charAt(0) == VARIABLE || fragments.get(i).equals(other.fragments.get(i))))
// return false;
// }
//
// return true;
// }
//
// /**
// * TODO : more URL fileds to hash. inefficient hash searching !
// *
// * we calculater hash code without url rest terms array content,
// * it will same as even rest array is diffrent. this can cause hashcode
// * is equaled when http method and url terms array size are same.
// *
// * HashMap (K, V) use hashcode() to determine which bucket is
// * used to hold the Entry. but get() use hashcode() and equals() to search
// * the Entry. so the correctness has no affected but search performance
// * on non-exist Entry searching.
// */
// @Override
// public int hashCode() {
// return requestMethod.name().hashCode() + fragments.size();
// }
//
// @Override
// public String toString() {
// return String.format("%s, %s", requestMethod.name(), Joiner.on("/").skipNulls().join(fragments));
// }
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/controller/URLController.java
// public class URLController extends Hitcounter {
//
// // target class
// private ControllerClassDescriptor provider;
// // target method
// private ControllerMethodDescriptor procedure;
// // internal controller sign. only for root-path
// private boolean internal = false;
//
// private URLController() {
//
// }
//
// public static URLController fromProvider(String URI, Class<?> providerClass, Method procedure) {
// URLController handler = new URLController();
// handler.provider = new ControllerClassDescriptor(providerClass);
// handler.procedure = new ControllerMethodDescriptor(URI, handler.provider, procedure);
// return handler;
// }
//
// public URLController internal() {
// this.internal = true;
// return this;
// }
//
// public boolean isInternal() {
// return this.internal;
// }
//
// public HttpResult call(HttpContext context) {
// /**
// * make new controller class instance with every http request. because
// * of we desire every request may has own context variables and status.
// *
// * TODO : This newInstance() need a empty param default constructor.
// *
// */
//
// try {
// Object result = procedure.invoke(context);
// if (result != null && !result.getClass().isPrimitive())
// return new HttpResult(ResultCode.SUCCESS, result);
// else
// return new HttpResult(ResultCode.RESPONSE_NOT_VALID);
// } catch (ControllerParamsNotMatchException e) {
// return new HttpResult(ResultCode.PARAMS_NOT_MATCHED);
// } catch (ControllerParamsParsedException e) {
// return new HttpResult(ResultCode.PARAMS_CONVERT_ERROR);
// }
// }
//
// @Override
// public String toString() {
// return String.format("provider=%s, procedure=%s", provider.getClazz().getCanonicalName(), procedure.getMethod().getName());
// }
// }
| import org.nesty.core.server.rest.URLResource;
import org.nesty.core.server.rest.controller.URLController;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong; | package org.nesty.core.server;
public class NestyServerMonitor {
// total missed request times
static final AtomicLong requestMiss = new AtomicLong();
// total hit request times
static final AtomicLong requestHit = new AtomicLong();
// total connections on current
static final AtomicLong connections = new AtomicLong();
// all URLResource mapping for hit count | // Path: core/src/main/java/org/nesty/core/server/rest/URLResource.java
// public class URLResource {
//
// // variable flag
// public static final char VARIABLE = '{';
// // resource identifier
// private URLResourceIdentifier identifier;
//
// private URLResource() {
//
// }
//
// public static URLResource fromHttp(String url, RequestMethod requestMethod) {
// URLResource resource = new URLResource();
// resource.identifier = URLResourceIdentifier.analyse(url);
// resource.identifier.requestMethod = requestMethod;
// return resource;
// }
//
// public RequestMethod requestMethod() {
// return identifier.requestMethod;
// }
//
// public List<String> fragments() {
// return identifier.fragments;
// }
//
// @Override
// public String toString() {
// return identifier.toString();
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public boolean equals(Object other) {
// return !(other == null || !(other instanceof URLResource)) && identifier.equals(((URLResource) other).identifier);
// }
//
// /**
// * URLResource uniqu identifier member. used for URLResource
// * equals and hashcode id
// */
// static class URLResourceIdentifier {
// protected List<String> fragments = new ArrayList<>(64);
// protected RequestMethod requestMethod;
//
// public static URLResourceIdentifier analyse(String url) {
// url = HttpUtils.truncateUrl(url);
// URLResourceIdentifier identifier = new URLResourceIdentifier();
// for (String s : Splitter.on('/').trimResults().omitEmptyStrings().split(url))
// identifier.fragments.add(s);
// return identifier;
// }
//
// @Override
// public boolean equals(Object object) {
// if (object == null || !(object instanceof URLResourceIdentifier))
// return false;
// URLResourceIdentifier other = (URLResourceIdentifier) object;
// if (requestMethod != other.requestMethod)
// return false;
// // rest array is not nessary
// if (fragments.size() != other.fragments.size())
// return false;
// for (int i = 0; i != fragments.size(); i++) {
// if (!(fragments.get(i).charAt(0) == VARIABLE || other.fragments.get(i).charAt(0) == VARIABLE || fragments.get(i).equals(other.fragments.get(i))))
// return false;
// }
//
// return true;
// }
//
// /**
// * TODO : more URL fileds to hash. inefficient hash searching !
// *
// * we calculater hash code without url rest terms array content,
// * it will same as even rest array is diffrent. this can cause hashcode
// * is equaled when http method and url terms array size are same.
// *
// * HashMap (K, V) use hashcode() to determine which bucket is
// * used to hold the Entry. but get() use hashcode() and equals() to search
// * the Entry. so the correctness has no affected but search performance
// * on non-exist Entry searching.
// */
// @Override
// public int hashCode() {
// return requestMethod.name().hashCode() + fragments.size();
// }
//
// @Override
// public String toString() {
// return String.format("%s, %s", requestMethod.name(), Joiner.on("/").skipNulls().join(fragments));
// }
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/controller/URLController.java
// public class URLController extends Hitcounter {
//
// // target class
// private ControllerClassDescriptor provider;
// // target method
// private ControllerMethodDescriptor procedure;
// // internal controller sign. only for root-path
// private boolean internal = false;
//
// private URLController() {
//
// }
//
// public static URLController fromProvider(String URI, Class<?> providerClass, Method procedure) {
// URLController handler = new URLController();
// handler.provider = new ControllerClassDescriptor(providerClass);
// handler.procedure = new ControllerMethodDescriptor(URI, handler.provider, procedure);
// return handler;
// }
//
// public URLController internal() {
// this.internal = true;
// return this;
// }
//
// public boolean isInternal() {
// return this.internal;
// }
//
// public HttpResult call(HttpContext context) {
// /**
// * make new controller class instance with every http request. because
// * of we desire every request may has own context variables and status.
// *
// * TODO : This newInstance() need a empty param default constructor.
// *
// */
//
// try {
// Object result = procedure.invoke(context);
// if (result != null && !result.getClass().isPrimitive())
// return new HttpResult(ResultCode.SUCCESS, result);
// else
// return new HttpResult(ResultCode.RESPONSE_NOT_VALID);
// } catch (ControllerParamsNotMatchException e) {
// return new HttpResult(ResultCode.PARAMS_NOT_MATCHED);
// } catch (ControllerParamsParsedException e) {
// return new HttpResult(ResultCode.PARAMS_CONVERT_ERROR);
// }
// }
//
// @Override
// public String toString() {
// return String.format("provider=%s, procedure=%s", provider.getClazz().getCanonicalName(), procedure.getMethod().getName());
// }
// }
// Path: core/src/main/java/org/nesty/core/server/NestyServerMonitor.java
import org.nesty.core.server.rest.URLResource;
import org.nesty.core.server.rest.controller.URLController;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
package org.nesty.core.server;
public class NestyServerMonitor {
// total missed request times
static final AtomicLong requestMiss = new AtomicLong();
// total hit request times
static final AtomicLong requestHit = new AtomicLong();
// total connections on current
static final AtomicLong connections = new AtomicLong();
// all URLResource mapping for hit count | static Map<URLResource, URLController> resourceMap = new HashMap<>(); |
gugemichael/nesty | core/src/main/java/org/nesty/core/server/NestyServerMonitor.java | // Path: core/src/main/java/org/nesty/core/server/rest/URLResource.java
// public class URLResource {
//
// // variable flag
// public static final char VARIABLE = '{';
// // resource identifier
// private URLResourceIdentifier identifier;
//
// private URLResource() {
//
// }
//
// public static URLResource fromHttp(String url, RequestMethod requestMethod) {
// URLResource resource = new URLResource();
// resource.identifier = URLResourceIdentifier.analyse(url);
// resource.identifier.requestMethod = requestMethod;
// return resource;
// }
//
// public RequestMethod requestMethod() {
// return identifier.requestMethod;
// }
//
// public List<String> fragments() {
// return identifier.fragments;
// }
//
// @Override
// public String toString() {
// return identifier.toString();
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public boolean equals(Object other) {
// return !(other == null || !(other instanceof URLResource)) && identifier.equals(((URLResource) other).identifier);
// }
//
// /**
// * URLResource uniqu identifier member. used for URLResource
// * equals and hashcode id
// */
// static class URLResourceIdentifier {
// protected List<String> fragments = new ArrayList<>(64);
// protected RequestMethod requestMethod;
//
// public static URLResourceIdentifier analyse(String url) {
// url = HttpUtils.truncateUrl(url);
// URLResourceIdentifier identifier = new URLResourceIdentifier();
// for (String s : Splitter.on('/').trimResults().omitEmptyStrings().split(url))
// identifier.fragments.add(s);
// return identifier;
// }
//
// @Override
// public boolean equals(Object object) {
// if (object == null || !(object instanceof URLResourceIdentifier))
// return false;
// URLResourceIdentifier other = (URLResourceIdentifier) object;
// if (requestMethod != other.requestMethod)
// return false;
// // rest array is not nessary
// if (fragments.size() != other.fragments.size())
// return false;
// for (int i = 0; i != fragments.size(); i++) {
// if (!(fragments.get(i).charAt(0) == VARIABLE || other.fragments.get(i).charAt(0) == VARIABLE || fragments.get(i).equals(other.fragments.get(i))))
// return false;
// }
//
// return true;
// }
//
// /**
// * TODO : more URL fileds to hash. inefficient hash searching !
// *
// * we calculater hash code without url rest terms array content,
// * it will same as even rest array is diffrent. this can cause hashcode
// * is equaled when http method and url terms array size are same.
// *
// * HashMap (K, V) use hashcode() to determine which bucket is
// * used to hold the Entry. but get() use hashcode() and equals() to search
// * the Entry. so the correctness has no affected but search performance
// * on non-exist Entry searching.
// */
// @Override
// public int hashCode() {
// return requestMethod.name().hashCode() + fragments.size();
// }
//
// @Override
// public String toString() {
// return String.format("%s, %s", requestMethod.name(), Joiner.on("/").skipNulls().join(fragments));
// }
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/controller/URLController.java
// public class URLController extends Hitcounter {
//
// // target class
// private ControllerClassDescriptor provider;
// // target method
// private ControllerMethodDescriptor procedure;
// // internal controller sign. only for root-path
// private boolean internal = false;
//
// private URLController() {
//
// }
//
// public static URLController fromProvider(String URI, Class<?> providerClass, Method procedure) {
// URLController handler = new URLController();
// handler.provider = new ControllerClassDescriptor(providerClass);
// handler.procedure = new ControllerMethodDescriptor(URI, handler.provider, procedure);
// return handler;
// }
//
// public URLController internal() {
// this.internal = true;
// return this;
// }
//
// public boolean isInternal() {
// return this.internal;
// }
//
// public HttpResult call(HttpContext context) {
// /**
// * make new controller class instance with every http request. because
// * of we desire every request may has own context variables and status.
// *
// * TODO : This newInstance() need a empty param default constructor.
// *
// */
//
// try {
// Object result = procedure.invoke(context);
// if (result != null && !result.getClass().isPrimitive())
// return new HttpResult(ResultCode.SUCCESS, result);
// else
// return new HttpResult(ResultCode.RESPONSE_NOT_VALID);
// } catch (ControllerParamsNotMatchException e) {
// return new HttpResult(ResultCode.PARAMS_NOT_MATCHED);
// } catch (ControllerParamsParsedException e) {
// return new HttpResult(ResultCode.PARAMS_CONVERT_ERROR);
// }
// }
//
// @Override
// public String toString() {
// return String.format("provider=%s, procedure=%s", provider.getClazz().getCanonicalName(), procedure.getMethod().getName());
// }
// }
| import org.nesty.core.server.rest.URLResource;
import org.nesty.core.server.rest.controller.URLController;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong; | package org.nesty.core.server;
public class NestyServerMonitor {
// total missed request times
static final AtomicLong requestMiss = new AtomicLong();
// total hit request times
static final AtomicLong requestHit = new AtomicLong();
// total connections on current
static final AtomicLong connections = new AtomicLong();
// all URLResource mapping for hit count | // Path: core/src/main/java/org/nesty/core/server/rest/URLResource.java
// public class URLResource {
//
// // variable flag
// public static final char VARIABLE = '{';
// // resource identifier
// private URLResourceIdentifier identifier;
//
// private URLResource() {
//
// }
//
// public static URLResource fromHttp(String url, RequestMethod requestMethod) {
// URLResource resource = new URLResource();
// resource.identifier = URLResourceIdentifier.analyse(url);
// resource.identifier.requestMethod = requestMethod;
// return resource;
// }
//
// public RequestMethod requestMethod() {
// return identifier.requestMethod;
// }
//
// public List<String> fragments() {
// return identifier.fragments;
// }
//
// @Override
// public String toString() {
// return identifier.toString();
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public boolean equals(Object other) {
// return !(other == null || !(other instanceof URLResource)) && identifier.equals(((URLResource) other).identifier);
// }
//
// /**
// * URLResource uniqu identifier member. used for URLResource
// * equals and hashcode id
// */
// static class URLResourceIdentifier {
// protected List<String> fragments = new ArrayList<>(64);
// protected RequestMethod requestMethod;
//
// public static URLResourceIdentifier analyse(String url) {
// url = HttpUtils.truncateUrl(url);
// URLResourceIdentifier identifier = new URLResourceIdentifier();
// for (String s : Splitter.on('/').trimResults().omitEmptyStrings().split(url))
// identifier.fragments.add(s);
// return identifier;
// }
//
// @Override
// public boolean equals(Object object) {
// if (object == null || !(object instanceof URLResourceIdentifier))
// return false;
// URLResourceIdentifier other = (URLResourceIdentifier) object;
// if (requestMethod != other.requestMethod)
// return false;
// // rest array is not nessary
// if (fragments.size() != other.fragments.size())
// return false;
// for (int i = 0; i != fragments.size(); i++) {
// if (!(fragments.get(i).charAt(0) == VARIABLE || other.fragments.get(i).charAt(0) == VARIABLE || fragments.get(i).equals(other.fragments.get(i))))
// return false;
// }
//
// return true;
// }
//
// /**
// * TODO : more URL fileds to hash. inefficient hash searching !
// *
// * we calculater hash code without url rest terms array content,
// * it will same as even rest array is diffrent. this can cause hashcode
// * is equaled when http method and url terms array size are same.
// *
// * HashMap (K, V) use hashcode() to determine which bucket is
// * used to hold the Entry. but get() use hashcode() and equals() to search
// * the Entry. so the correctness has no affected but search performance
// * on non-exist Entry searching.
// */
// @Override
// public int hashCode() {
// return requestMethod.name().hashCode() + fragments.size();
// }
//
// @Override
// public String toString() {
// return String.format("%s, %s", requestMethod.name(), Joiner.on("/").skipNulls().join(fragments));
// }
// }
// }
//
// Path: core/src/main/java/org/nesty/core/server/rest/controller/URLController.java
// public class URLController extends Hitcounter {
//
// // target class
// private ControllerClassDescriptor provider;
// // target method
// private ControllerMethodDescriptor procedure;
// // internal controller sign. only for root-path
// private boolean internal = false;
//
// private URLController() {
//
// }
//
// public static URLController fromProvider(String URI, Class<?> providerClass, Method procedure) {
// URLController handler = new URLController();
// handler.provider = new ControllerClassDescriptor(providerClass);
// handler.procedure = new ControllerMethodDescriptor(URI, handler.provider, procedure);
// return handler;
// }
//
// public URLController internal() {
// this.internal = true;
// return this;
// }
//
// public boolean isInternal() {
// return this.internal;
// }
//
// public HttpResult call(HttpContext context) {
// /**
// * make new controller class instance with every http request. because
// * of we desire every request may has own context variables and status.
// *
// * TODO : This newInstance() need a empty param default constructor.
// *
// */
//
// try {
// Object result = procedure.invoke(context);
// if (result != null && !result.getClass().isPrimitive())
// return new HttpResult(ResultCode.SUCCESS, result);
// else
// return new HttpResult(ResultCode.RESPONSE_NOT_VALID);
// } catch (ControllerParamsNotMatchException e) {
// return new HttpResult(ResultCode.PARAMS_NOT_MATCHED);
// } catch (ControllerParamsParsedException e) {
// return new HttpResult(ResultCode.PARAMS_CONVERT_ERROR);
// }
// }
//
// @Override
// public String toString() {
// return String.format("provider=%s, procedure=%s", provider.getClazz().getCanonicalName(), procedure.getMethod().getName());
// }
// }
// Path: core/src/main/java/org/nesty/core/server/NestyServerMonitor.java
import org.nesty.core.server.rest.URLResource;
import org.nesty.core.server.rest.controller.URLController;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
package org.nesty.core.server;
public class NestyServerMonitor {
// total missed request times
static final AtomicLong requestMiss = new AtomicLong();
// total hit request times
static final AtomicLong requestHit = new AtomicLong();
// total connections on current
static final AtomicLong connections = new AtomicLong();
// all URLResource mapping for hit count | static Map<URLResource, URLController> resourceMap = new HashMap<>(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-portal/src/main/java/cn/binux/portal/service/impl/PortalContentServiceImpl.java | // Path: xbin-store-cloud-service-portal-api/src/main/java/cn/binux/portal/service/PortalContentService.java
// @FeignClient(value = "xbin-store-cloud-service-portal",fallback = PortalContentServiceHystrix.class)
// public interface PortalContentService {
//
// @RequestMapping(value = "/getContentByCid",method = RequestMethod.POST)
// List<TbContent> getContentByCid(@RequestParam("bigAdIndex") Long bigAdIndex);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.mapper.TbContentMapper;
import cn.binux.pojo.TbContent;
import cn.binux.pojo.TbContentExample;
import cn.binux.portal.service.PortalContentService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; | package cn.binux.portal.service.impl;
/**
* 首页内容Service
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope | // Path: xbin-store-cloud-service-portal-api/src/main/java/cn/binux/portal/service/PortalContentService.java
// @FeignClient(value = "xbin-store-cloud-service-portal",fallback = PortalContentServiceHystrix.class)
// public interface PortalContentService {
//
// @RequestMapping(value = "/getContentByCid",method = RequestMethod.POST)
// List<TbContent> getContentByCid(@RequestParam("bigAdIndex") Long bigAdIndex);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-portal/src/main/java/cn/binux/portal/service/impl/PortalContentServiceImpl.java
import cn.binux.mapper.TbContentMapper;
import cn.binux.pojo.TbContent;
import cn.binux.pojo.TbContentExample;
import cn.binux.portal.service.PortalContentService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
package cn.binux.portal.service.impl;
/**
* 首页内容Service
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope | public class PortalContentServiceImpl implements PortalContentService { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-portal/src/main/java/cn/binux/portal/service/impl/PortalContentServiceImpl.java | // Path: xbin-store-cloud-service-portal-api/src/main/java/cn/binux/portal/service/PortalContentService.java
// @FeignClient(value = "xbin-store-cloud-service-portal",fallback = PortalContentServiceHystrix.class)
// public interface PortalContentService {
//
// @RequestMapping(value = "/getContentByCid",method = RequestMethod.POST)
// List<TbContent> getContentByCid(@RequestParam("bigAdIndex") Long bigAdIndex);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.mapper.TbContentMapper;
import cn.binux.pojo.TbContent;
import cn.binux.pojo.TbContentExample;
import cn.binux.portal.service.PortalContentService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; | package cn.binux.portal.service.impl;
/**
* 首页内容Service
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope
public class PortalContentServiceImpl implements PortalContentService {
private static Logger logger = Logger.getLogger(PortalContentServiceImpl.class);
@Autowired
private TbContentMapper contentMapper;
@Autowired | // Path: xbin-store-cloud-service-portal-api/src/main/java/cn/binux/portal/service/PortalContentService.java
// @FeignClient(value = "xbin-store-cloud-service-portal",fallback = PortalContentServiceHystrix.class)
// public interface PortalContentService {
//
// @RequestMapping(value = "/getContentByCid",method = RequestMethod.POST)
// List<TbContent> getContentByCid(@RequestParam("bigAdIndex") Long bigAdIndex);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-portal/src/main/java/cn/binux/portal/service/impl/PortalContentServiceImpl.java
import cn.binux.mapper.TbContentMapper;
import cn.binux.pojo.TbContent;
import cn.binux.pojo.TbContentExample;
import cn.binux.portal.service.PortalContentService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
package cn.binux.portal.service.impl;
/**
* 首页内容Service
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope
public class PortalContentServiceImpl implements PortalContentService {
private static Logger logger = Logger.getLogger(PortalContentServiceImpl.class);
@Autowired
private TbContentMapper contentMapper;
@Autowired | private JedisClient jedisClient; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-sso/src/main/java/cn/binux/XbinStoreServiceSSOApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceSSOApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-sso/src/main/java/cn/binux/XbinStoreServiceSSOApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceSSOApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-sso/src/main/java/cn/binux/XbinStoreServiceSSOApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceSSOApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-sso/src/main/java/cn/binux/XbinStoreServiceSSOApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceSSOApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/hystrix/ContentServiceHystrix.java
// @Component
// public class ContentServiceHystrix implements ContentService {
//
//
// @Override
// public Map<String, Object> getCategoryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
// return null;
// }
//
// @Override
// public XbinResult saveCategory(String id, String name, Integer sort_order) {
// return null;
// }
//
// @Override
// public Map<String, Object> getCategorySecondaryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
// return null;
// }
//
// @Override
// public Map<String, Object> getSearchCategorySecondaryList(String sSearch, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
// return null;
// }
//
// @Override
// public XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary) {
// return null;
// }
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.admin.service.hystrix.ContentServiceHystrix;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map; | package cn.binux.admin.service;
/**
* 内容维护
*
* @author xubin.
* @create 2017-04-27
*/
@FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
public interface ContentService {
@RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
Map<String, Object> getCategoryList(
@RequestParam("sEcho") Integer sEcho,
@RequestParam("iDisplayStart") Integer iDisplayStart,
@RequestParam("iDisplayLength") Integer iDisplayLength
);
@RequestMapping(value = "/save/category",method = RequestMethod.POST) | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/hystrix/ContentServiceHystrix.java
// @Component
// public class ContentServiceHystrix implements ContentService {
//
//
// @Override
// public Map<String, Object> getCategoryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
// return null;
// }
//
// @Override
// public XbinResult saveCategory(String id, String name, Integer sort_order) {
// return null;
// }
//
// @Override
// public Map<String, Object> getCategorySecondaryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
// return null;
// }
//
// @Override
// public Map<String, Object> getSearchCategorySecondaryList(String sSearch, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
// return null;
// }
//
// @Override
// public XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary) {
// return null;
// }
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
import cn.binux.admin.service.hystrix.ContentServiceHystrix;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
package cn.binux.admin.service;
/**
* 内容维护
*
* @author xubin.
* @create 2017-04-27
*/
@FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
public interface ContentService {
@RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
Map<String, Object> getCategoryList(
@RequestParam("sEcho") Integer sEcho,
@RequestParam("iDisplayStart") Integer iDisplayStart,
@RequestParam("iDisplayLength") Integer iDisplayLength
);
@RequestMapping(value = "/save/category",method = RequestMethod.POST) | XbinResult saveCategory( |
xubinux/xbin-store-cloud | xbin-store-cloud-web-cart/src/main/java/cn/binux/XbinStoreWebCartApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
@EnableHystrix
//@EnableApolloConfig
public class XbinStoreWebCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebCartApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-web-cart/src/main/java/cn/binux/XbinStoreWebCartApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
@EnableHystrix
//@EnableApolloConfig
public class XbinStoreWebCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebCartApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-web-cart/src/main/java/cn/binux/XbinStoreWebCartApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
@EnableHystrix
//@EnableApolloConfig
public class XbinStoreWebCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebCartApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-web-cart/src/main/java/cn/binux/XbinStoreWebCartApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
@EnableHystrix
//@EnableApolloConfig
public class XbinStoreWebCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebCartApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-web-sso/src/main/java/cn/binux/XbinStoreWebSSOApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebSSOApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-web-sso/src/main/java/cn/binux/XbinStoreWebSSOApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebSSOApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-web-sso/src/main/java/cn/binux/XbinStoreWebSSOApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebSSOApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-web-sso/src/main/java/cn/binux/XbinStoreWebSSOApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebSSOApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebSSOApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-cart/src/main/java/cn/binux/XbinStoreServiceCartApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceCartApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-cart/src/main/java/cn/binux/XbinStoreServiceCartApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceCartApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-cart/src/main/java/cn/binux/XbinStoreServiceCartApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceCartApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-cart/src/main/java/cn/binux/XbinStoreServiceCartApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceCartApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceCartApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-notify/src/main/java/cn/binux/XbinStoreServiceNotifyApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
public class XbinStoreServiceNotifyApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceNotifyApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-notify/src/main/java/cn/binux/XbinStoreServiceNotifyApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
public class XbinStoreServiceNotifyApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceNotifyApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-notify/src/main/java/cn/binux/XbinStoreServiceNotifyApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
public class XbinStoreServiceNotifyApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceNotifyApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-notify/src/main/java/cn/binux/XbinStoreServiceNotifyApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
public class XbinStoreServiceNotifyApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceNotifyApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-web-item/src/main/java/cn/binux/item/controller/ItemController.java | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
| import cn.binux.item.service.ItemService;
import cn.binux.item.vo.TbItemVO;
import cn.binux.pojo.TbItemDesc;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; | package cn.binux.item.controller;
/**
* 商品查询 Controller
*
* @author xubin.
* @create 2017-05-04
*/
@Api(value = "API - ItemController", description = "商品 Controller")
@Controller
public class ItemController {
private static final Logger logger = LoggerFactory.getLogger(ItemController.class);
@Autowired | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
// Path: xbin-store-cloud-web-item/src/main/java/cn/binux/item/controller/ItemController.java
import cn.binux.item.service.ItemService;
import cn.binux.item.vo.TbItemVO;
import cn.binux.pojo.TbItemDesc;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
package cn.binux.item.controller;
/**
* 商品查询 Controller
*
* @author xubin.
* @create 2017-05-04
*/
@Api(value = "API - ItemController", description = "商品 Controller")
@Controller
public class ItemController {
private static final Logger logger = LoggerFactory.getLogger(ItemController.class);
@Autowired | private ItemService itemService; |
xubinux/xbin-store-cloud | xbin-store-cloud-web-order/src/main/java/cn/binux/XbinStoreWebOrderApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebOrderApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-web-order/src/main/java/cn/binux/XbinStoreWebOrderApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebOrderApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-web-order/src/main/java/cn/binux/XbinStoreWebOrderApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebOrderApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-web-order/src/main/java/cn/binux/XbinStoreWebOrderApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package cn.binux;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@Configuration
//@EnableApolloConfig
@EnableHystrix
public class XbinStoreWebOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreWebOrderApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-item/src/main/java/cn/binux/item/service/impl/ItemServiceImpl.java | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.item.service.ItemService;
import cn.binux.mapper.TbItemDescMapper;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemDesc;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; | package cn.binux.item.service.impl;
/**
* 商品 Service 实现
*
* @author xubin.
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-item/src/main/java/cn/binux/item/service/impl/ItemServiceImpl.java
import cn.binux.item.service.ItemService;
import cn.binux.mapper.TbItemDescMapper;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemDesc;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
package cn.binux.item.service.impl;
/**
* 商品 Service 实现
*
* @author xubin.
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope | public class ItemServiceImpl implements ItemService { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-item/src/main/java/cn/binux/item/service/impl/ItemServiceImpl.java | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.item.service.ItemService;
import cn.binux.mapper.TbItemDescMapper;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemDesc;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; | package cn.binux.item.service.impl;
/**
* 商品 Service 实现
*
* @author xubin.
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope
public class ItemServiceImpl implements ItemService {
private static final Logger logger = LoggerFactory.getLogger(ItemServiceImpl.class);
@Autowired
private TbItemMapper itemMapper;
@Autowired
private TbItemDescMapper itemDescMapper;
@Autowired | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-item/src/main/java/cn/binux/item/service/impl/ItemServiceImpl.java
import cn.binux.item.service.ItemService;
import cn.binux.mapper.TbItemDescMapper;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemDesc;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
package cn.binux.item.service.impl;
/**
* 商品 Service 实现
*
* @author xubin.
* @create 2017-05-04
*/
@Api(value = "API - PortalContentServiceImpl", description = "首页操作")
@RestController
@RefreshScope
public class ItemServiceImpl implements ItemService {
private static final Logger logger = LoggerFactory.getLogger(ItemServiceImpl.class);
@Autowired
private TbItemMapper itemMapper;
@Autowired
private TbItemDescMapper itemDescMapper;
@Autowired | private JedisClient jedisClient; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-item/src/main/java/cn/binux/XbinStoreServiceItemApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceItemApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceItemApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-item/src/main/java/cn/binux/XbinStoreServiceItemApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceItemApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceItemApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-item/src/main/java/cn/binux/XbinStoreServiceItemApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceItemApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceItemApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-item/src/main/java/cn/binux/XbinStoreServiceItemApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
@SpringBootApplication
@EnableDiscoveryClient
//@EnableApolloConfig
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceItemApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceItemApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/hystrix/OrderServiceHystrix.java | // Path: xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/OrderService.java
// @FeignClient(value = "xbin-store-cloud-service-order",fallback = OrderServiceHystrix.class)
// public interface OrderService {
// /**
// * 提交订单
// *
// * @param userCookieValue 用户登录Cookie
// * @param cartCookieValue 购物车Cookie
// * @param addrId 用户地址id
// * @param noAnnoyance 运费险
// * @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
// * @param shippingName 快递名称 固定顺丰速运
// * @return
// */
// @RequestMapping(value = "/generateOrder",method = RequestMethod.POST)
// XbinResult generateOrder(
// @RequestParam("userCookieValue") String userCookieValue,
// @RequestParam("cartCookieValue") String cartCookieValue,
// @RequestParam("addrId") Integer addrId,
// @RequestParam("noAnnoyance") Integer noAnnoyance,
// @RequestParam("paymentType") Integer paymentType,
// @RequestParam("orderId") String orderId,
// @RequestParam("shippingName") String shippingName
// );
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.order.service.OrderService;
import cn.binux.pojo.XbinResult;
import org.springframework.stereotype.Component; | package cn.binux.order.service.hystrix;
/**
* 订单服务 熔断处理
*
* @author xubin.
* @create 2017-05-05
*/
@Component
public class OrderServiceHystrix implements OrderService {
/**
* 提交订单
*
* @param userCookieValue 用户登录Cookie
* @param cartCookieValue 购物车Cookie
* @param addrId 用户地址id
* @param noAnnoyance 运费险
* @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
* @param orderId
* @param shippingName 快递名称 固定顺丰速运 @return
*/
@Override | // Path: xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/OrderService.java
// @FeignClient(value = "xbin-store-cloud-service-order",fallback = OrderServiceHystrix.class)
// public interface OrderService {
// /**
// * 提交订单
// *
// * @param userCookieValue 用户登录Cookie
// * @param cartCookieValue 购物车Cookie
// * @param addrId 用户地址id
// * @param noAnnoyance 运费险
// * @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
// * @param shippingName 快递名称 固定顺丰速运
// * @return
// */
// @RequestMapping(value = "/generateOrder",method = RequestMethod.POST)
// XbinResult generateOrder(
// @RequestParam("userCookieValue") String userCookieValue,
// @RequestParam("cartCookieValue") String cartCookieValue,
// @RequestParam("addrId") Integer addrId,
// @RequestParam("noAnnoyance") Integer noAnnoyance,
// @RequestParam("paymentType") Integer paymentType,
// @RequestParam("orderId") String orderId,
// @RequestParam("shippingName") String shippingName
// );
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/hystrix/OrderServiceHystrix.java
import cn.binux.order.service.OrderService;
import cn.binux.pojo.XbinResult;
import org.springframework.stereotype.Component;
package cn.binux.order.service.hystrix;
/**
* 订单服务 熔断处理
*
* @author xubin.
* @create 2017-05-05
*/
@Component
public class OrderServiceHystrix implements OrderService {
/**
* 提交订单
*
* @param userCookieValue 用户登录Cookie
* @param cartCookieValue 购物车Cookie
* @param addrId 用户地址id
* @param noAnnoyance 运费险
* @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
* @param orderId
* @param shippingName 快递名称 固定顺丰速运 @return
*/
@Override | public XbinResult generateOrder(String userCookieValue, String cartCookieValue, Integer addrId, Integer noAnnoyance, Integer paymentType, String orderId, String shippingName) { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-notify/src/main/java/cn/binux/notify/service/impl/NotifyUserServiceImpl.java | // Path: xbin-store-cloud-service-notify-api/src/main/java/cn/binux/notify/service/NotifyUserService.java
// @FeignClient(value = "xbin-store-cloud-service-notify",fallback = NotifyUserServiceHystrix.class)
// public interface NotifyUserService {
// /**
// * 发送短信
// *
// * @param mobile 手机号码 带国际区号
// * @return ({"rs":1}) 第一次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第二次提示还有2次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第三次提示还有1次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第四次提示此号码发送短信已达上限 请于1小时后尝试
// * ({"rs":-1}) 网络繁忙
// */
// @RequestMapping(value = "/mobileNotify/{mobile}",method = RequestMethod.POST)
// String mobileNotify(@PathVariable("mobile") String mobile);
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.notify.service.NotifyUserService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; | package cn.binux.notify.service.impl;
/**
* 用户通知服务实现
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - NotifyUserServiceImpl", description = "用户通知")
@RefreshScope
@RestController | // Path: xbin-store-cloud-service-notify-api/src/main/java/cn/binux/notify/service/NotifyUserService.java
// @FeignClient(value = "xbin-store-cloud-service-notify",fallback = NotifyUserServiceHystrix.class)
// public interface NotifyUserService {
// /**
// * 发送短信
// *
// * @param mobile 手机号码 带国际区号
// * @return ({"rs":1}) 第一次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第二次提示还有2次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第三次提示还有1次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第四次提示此号码发送短信已达上限 请于1小时后尝试
// * ({"rs":-1}) 网络繁忙
// */
// @RequestMapping(value = "/mobileNotify/{mobile}",method = RequestMethod.POST)
// String mobileNotify(@PathVariable("mobile") String mobile);
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-notify/src/main/java/cn/binux/notify/service/impl/NotifyUserServiceImpl.java
import cn.binux.notify.service.NotifyUserService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
package cn.binux.notify.service.impl;
/**
* 用户通知服务实现
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - NotifyUserServiceImpl", description = "用户通知")
@RefreshScope
@RestController | public class NotifyUserServiceImpl implements NotifyUserService { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-notify/src/main/java/cn/binux/notify/service/impl/NotifyUserServiceImpl.java | // Path: xbin-store-cloud-service-notify-api/src/main/java/cn/binux/notify/service/NotifyUserService.java
// @FeignClient(value = "xbin-store-cloud-service-notify",fallback = NotifyUserServiceHystrix.class)
// public interface NotifyUserService {
// /**
// * 发送短信
// *
// * @param mobile 手机号码 带国际区号
// * @return ({"rs":1}) 第一次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第二次提示还有2次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第三次提示还有1次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第四次提示此号码发送短信已达上限 请于1小时后尝试
// * ({"rs":-1}) 网络繁忙
// */
// @RequestMapping(value = "/mobileNotify/{mobile}",method = RequestMethod.POST)
// String mobileNotify(@PathVariable("mobile") String mobile);
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.notify.service.NotifyUserService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; | package cn.binux.notify.service.impl;
/**
* 用户通知服务实现
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - NotifyUserServiceImpl", description = "用户通知")
@RefreshScope
@RestController
public class NotifyUserServiceImpl implements NotifyUserService {
private static final Logger logger = LoggerFactory.getLogger(NotifyUserServiceImpl.class);
@Autowired | // Path: xbin-store-cloud-service-notify-api/src/main/java/cn/binux/notify/service/NotifyUserService.java
// @FeignClient(value = "xbin-store-cloud-service-notify",fallback = NotifyUserServiceHystrix.class)
// public interface NotifyUserService {
// /**
// * 发送短信
// *
// * @param mobile 手机号码 带国际区号
// * @return ({"rs":1}) 第一次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第二次提示还有2次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第三次提示还有1次
// * ({'remain':'\u8be5\u624b\u673a\u8fd8\u53ef\u83b7\u53d62\u6b21\u9a8c\u8bc1\u7801\uff0c\u8bf7\u5c3d\u5feb\u5b8c\u6210\u9a8c\u8bc1'})
// * 第四次提示此号码发送短信已达上限 请于1小时后尝试
// * ({"rs":-1}) 网络繁忙
// */
// @RequestMapping(value = "/mobileNotify/{mobile}",method = RequestMethod.POST)
// String mobileNotify(@PathVariable("mobile") String mobile);
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-notify/src/main/java/cn/binux/notify/service/impl/NotifyUserServiceImpl.java
import cn.binux.notify.service.NotifyUserService;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
package cn.binux.notify.service.impl;
/**
* 用户通知服务实现
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - NotifyUserServiceImpl", description = "用户通知")
@RefreshScope
@RestController
public class NotifyUserServiceImpl implements NotifyUserService {
private static final Logger logger = LoggerFactory.getLogger(NotifyUserServiceImpl.class);
@Autowired | private JedisClient jedisClient; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/hystrix/ContentServiceHystrix.java | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.admin.service.ContentService;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.springframework.stereotype.Component;
import java.util.Map; | package cn.binux.admin.service.hystrix;
/**
* 内容维护 熔断处理
*
* @author xubin.
* @create 2017-04-27 上午11:40
*/
@Component
public class ContentServiceHystrix implements ContentService {
@Override
public Map<String, Object> getCategoryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
return null;
}
@Override | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/hystrix/ContentServiceHystrix.java
import cn.binux.admin.service.ContentService;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.springframework.stereotype.Component;
import java.util.Map;
package cn.binux.admin.service.hystrix;
/**
* 内容维护 熔断处理
*
* @author xubin.
* @create 2017-04-27 上午11:40
*/
@Component
public class ContentServiceHystrix implements ContentService {
@Override
public Map<String, Object> getCategoryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
return null;
}
@Override | public XbinResult saveCategory(String id, String name, Integer sort_order) { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-admin/src/main/java/cn/binux/admin/service/impl/ContentServiceImpl.java | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
| import cn.binux.admin.service.ContentService;
import cn.binux.mapper.TbCategoryMapper;
import cn.binux.mapper.TbCategorySecondaryMapper;
import cn.binux.pojo.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package cn.binux.admin.service.impl;
/**
* 内容维护 Service
*
* @author xubin.
* @create 2017-04-28
*/
@Api(value = "API - ContentServiceImpl", description = "内容操作")
@RestController | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
// Path: xbin-store-cloud-service-admin/src/main/java/cn/binux/admin/service/impl/ContentServiceImpl.java
import cn.binux.admin.service.ContentService;
import cn.binux.mapper.TbCategoryMapper;
import cn.binux.mapper.TbCategorySecondaryMapper;
import cn.binux.pojo.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package cn.binux.admin.service.impl;
/**
* 内容维护 Service
*
* @author xubin.
* @create 2017-04-28
*/
@Api(value = "API - ContentServiceImpl", description = "内容操作")
@RestController | public class ContentServiceImpl implements ContentService { |
xubinux/xbin-store-cloud | xbin-store-cloud-web-search/src/main/java/cn/binux/search/controller/SearchController.java | // Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
// @FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
// public interface SearchService {
//
// //http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @RequestMapping(value = "/importAllItems",method = RequestMethod.POST)
// XbinResult importAllItems();
//
// //http://localhost:8512/search/SolrService/search/查询条件/1/60
// /**
// * 查询商品
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @RequestMapping(value = "/search",method = RequestMethod.POST)
// SearchResult search(
// @RequestParam("q") String queryString,
// @RequestParam(name = "page",defaultValue = "1") Integer page,
// @RequestParam(name = "rows",defaultValue = "0") Integer rows
// );
// }
| import cn.binux.pojo.SearchResult;
import cn.binux.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.UnsupportedEncodingException; | package cn.binux.search.controller;
/**
* 搜索 Controller
*
* @author xubin.
* @create 2017-05-04
*/
@Controller
@RefreshScope
public class SearchController {
@Autowired | // Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
// @FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
// public interface SearchService {
//
// //http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @RequestMapping(value = "/importAllItems",method = RequestMethod.POST)
// XbinResult importAllItems();
//
// //http://localhost:8512/search/SolrService/search/查询条件/1/60
// /**
// * 查询商品
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @RequestMapping(value = "/search",method = RequestMethod.POST)
// SearchResult search(
// @RequestParam("q") String queryString,
// @RequestParam(name = "page",defaultValue = "1") Integer page,
// @RequestParam(name = "rows",defaultValue = "0") Integer rows
// );
// }
// Path: xbin-store-cloud-web-search/src/main/java/cn/binux/search/controller/SearchController.java
import cn.binux.pojo.SearchResult;
import cn.binux.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.UnsupportedEncodingException;
package cn.binux.search.controller;
/**
* 搜索 Controller
*
* @author xubin.
* @create 2017-05-04
*/
@Controller
@RefreshScope
public class SearchController {
@Autowired | private SearchService searchService; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/hystrix/CartServiceHystrix.java | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.cart.service.CartService;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.XbinResult;
import org.springframework.stereotype.Component;
import java.util.List; | package cn.binux.cart.service.hystrix;
/**
* 购物车服务 熔断处理
*
* @author xubin.
* @create 2017-05-04 下午11:59
*/
@Component
public class CartServiceHystrix implements CartService {
@Override | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/hystrix/CartServiceHystrix.java
import cn.binux.cart.service.CartService;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.XbinResult;
import org.springframework.stereotype.Component;
import java.util.List;
package cn.binux.cart.service.hystrix;
/**
* 购物车服务 熔断处理
*
* @author xubin.
* @create 2017-05-04 下午11:59
*/
@Component
public class CartServiceHystrix implements CartService {
@Override | public XbinResult addCart(Long pid, Integer pcount, String uuid) { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-item/src/main/java/cn/binux/item/listener/ItemAddListener.java | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
| import cn.binux.item.service.ItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; | package cn.binux.item.listener;
/**
* 监听商品添加 生成商品页面静态文件
*
* @author xubin.
* @create 2017-02-06 下午8:19
*/
public class ItemAddListener {
private static final Logger logger = LoggerFactory.getLogger(ItemAddListener.class);
@Autowired | // Path: xbin-store-cloud-service-item-api/src/main/java/cn/binux/item/service/ItemService.java
// @FeignClient(value = "xbin-store-cloud-service-item",fallback = ItemServiceHystrix.class)
// public interface ItemService {
//
// @RequestMapping(value = "/getItemById/{id}",method = RequestMethod.POST)
// TbItem getItemById(@PathVariable("id") Long itemId);
//
// @RequestMapping(value = "/getItemDescById/{id}",method = RequestMethod.POST)
// TbItemDesc getItemDescById(@PathVariable("id") Long itemId);
//
//
// }
// Path: xbin-store-cloud-service-item/src/main/java/cn/binux/item/listener/ItemAddListener.java
import cn.binux.item.service.ItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
package cn.binux.item.listener;
/**
* 监听商品添加 生成商品页面静态文件
*
* @author xubin.
* @create 2017-02-06 下午8:19
*/
public class ItemAddListener {
private static final Logger logger = LoggerFactory.getLogger(ItemAddListener.class);
@Autowired | private ItemService itemService; |
xubinux/xbin-store-cloud | xbin-store-cloud-web-cart/src/main/java/cn/binux/cart/controller/CartController.java | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.cart.service.CartService;
import cn.binux.constant.Const;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbUser;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.CookieUtils;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; | package cn.binux.cart.controller;
/**
* 购物车 Controller
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - CartController", description = "购物车 Controller")
@Controller
@RefreshScope
public class CartController {
private static final Logger logger = LoggerFactory.getLogger(CartController.class);
@Autowired | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-web-cart/src/main/java/cn/binux/cart/controller/CartController.java
import cn.binux.cart.service.CartService;
import cn.binux.constant.Const;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbUser;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.CookieUtils;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
package cn.binux.cart.controller;
/**
* 购物车 Controller
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - CartController", description = "购物车 Controller")
@Controller
@RefreshScope
public class CartController {
private static final Logger logger = LoggerFactory.getLogger(CartController.class);
@Autowired | private CartService cartService; |
xubinux/xbin-store-cloud | xbin-store-cloud-web-cart/src/main/java/cn/binux/cart/controller/CartController.java | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.cart.service.CartService;
import cn.binux.constant.Const;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbUser;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.CookieUtils;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; | package cn.binux.cart.controller;
/**
* 购物车 Controller
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - CartController", description = "购物车 Controller")
@Controller
@RefreshScope
public class CartController {
private static final Logger logger = LoggerFactory.getLogger(CartController.class);
@Autowired
private CartService cartService;
@Autowired | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-web-cart/src/main/java/cn/binux/cart/controller/CartController.java
import cn.binux.cart.service.CartService;
import cn.binux.constant.Const;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbUser;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.CookieUtils;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
package cn.binux.cart.controller;
/**
* 购物车 Controller
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - CartController", description = "购物车 Controller")
@Controller
@RefreshScope
public class CartController {
private static final Logger logger = LoggerFactory.getLogger(CartController.class);
@Autowired
private CartService cartService;
@Autowired | private JedisClient jedisClient; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/hystrix/CartServiceHystrix.java
// @Component
// public class CartServiceHystrix implements CartService {
//
//
// @Override
// public XbinResult addCart(Long pid, Integer pcount, String uuid) {
// return null;
// }
//
// @Override
// public List<CartInfo> getCartInfoListByCookiesId(String cookieUUID) {
// return null;
// }
//
// @Override
// public XbinResult decreOrIncre(Long pid, Integer pcount, Integer type, Integer index, String cookieUUID) {
// return null;
// }
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.cart.service.hystrix.CartServiceHystrix;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.XbinResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; | package cn.binux.cart.service;
/**
* 购物车相关操作 Service
*
* @author xubin.
* @create 2017-05-04
*/
@FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
public interface CartService {
@RequestMapping(value = "/addCart",method = RequestMethod.POST) | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/hystrix/CartServiceHystrix.java
// @Component
// public class CartServiceHystrix implements CartService {
//
//
// @Override
// public XbinResult addCart(Long pid, Integer pcount, String uuid) {
// return null;
// }
//
// @Override
// public List<CartInfo> getCartInfoListByCookiesId(String cookieUUID) {
// return null;
// }
//
// @Override
// public XbinResult decreOrIncre(Long pid, Integer pcount, Integer type, Integer index, String cookieUUID) {
// return null;
// }
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
import cn.binux.cart.service.hystrix.CartServiceHystrix;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.XbinResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
package cn.binux.cart.service;
/**
* 购物车相关操作 Service
*
* @author xubin.
* @create 2017-05-04
*/
@FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
public interface CartService {
@RequestMapping(value = "/addCart",method = RequestMethod.POST) | XbinResult addCart( |
xubinux/xbin-store-cloud | xbin-store-cloud-service-cart/src/main/java/cn/binux/cart/service/impl/CartServiceImpl.java | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.cart.service.CartService;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemExample;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List; | package cn.binux.cart.service.impl;
/**
* 购物车操作实现
*
* @author xubin.
* @create 2017-02-22 下午12:51
*/
//@Transactional
@Api(value = "API - CartServiceImpl", description = "购物车操作")
@RestController
@RefreshScope | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-cart/src/main/java/cn/binux/cart/service/impl/CartServiceImpl.java
import cn.binux.cart.service.CartService;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemExample;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
package cn.binux.cart.service.impl;
/**
* 购物车操作实现
*
* @author xubin.
* @create 2017-02-22 下午12:51
*/
//@Transactional
@Api(value = "API - CartServiceImpl", description = "购物车操作")
@RestController
@RefreshScope | public class CartServiceImpl implements CartService { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-cart/src/main/java/cn/binux/cart/service/impl/CartServiceImpl.java | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.cart.service.CartService;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemExample;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List; | package cn.binux.cart.service.impl;
/**
* 购物车操作实现
*
* @author xubin.
* @create 2017-02-22 下午12:51
*/
//@Transactional
@Api(value = "API - CartServiceImpl", description = "购物车操作")
@RestController
@RefreshScope
public class CartServiceImpl implements CartService {
private static final Logger logger = LoggerFactory.getLogger(CartServiceImpl.class);
@Value("${redisKey.prefix.cart_info_profix}")
private String CART_INFO_PROFIX;
@Value("${redisKey.prefix.redis_cart_expire_time}")
private Integer REDIS_CART_EXPIRE_TIME;
@Value("${redisKey.prefix.item_info_profix}")
private String ITEM_INFO_PROFIX;
@Value("${redisKey.prefix.item_info_base_suffix}")
private String ITEM_INFO_BASE_SUFFIX;
@Autowired | // Path: xbin-store-cloud-service-cart-api/src/main/java/cn/binux/cart/service/CartService.java
// @FeignClient(value = "xbin-store-cloud-service-cart",fallback = CartServiceHystrix.class)
// public interface CartService {
//
// @RequestMapping(value = "/addCart",method = RequestMethod.POST)
// XbinResult addCart(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("uuid") String uuid
// );
//
// @RequestMapping(value = "/getCartInfoListByCookiesId",method = RequestMethod.POST)
// List<CartInfo> getCartInfoListByCookiesId(@RequestParam("cookieUUID") String cookieUUID);
//
// /**
// *
// * 根据商品id和数量对购物车增加商品或减少商品
// *
// * @param pid 商品id
// * @param pcount 增加数量
// * @param type 1 增加 2 减少
// * @param index 商品位置 ps:用于直接定位商品 不用遍历整个购物车
// * @return
// */
// @RequestMapping(value = "/decreOrIncre",method = RequestMethod.POST)
// XbinResult decreOrIncre(
// @RequestParam("pid") Long pid,
// @RequestParam("pcount") Integer pcount,
// @RequestParam("type") Integer type,
// @RequestParam("index") Integer index,
// @RequestParam("cookieUUID") String cookieUUID
// );
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-service-cart/src/main/java/cn/binux/cart/service/impl/CartServiceImpl.java
import cn.binux.cart.service.CartService;
import cn.binux.mapper.TbItemMapper;
import cn.binux.pojo.CartInfo;
import cn.binux.pojo.TbItem;
import cn.binux.pojo.TbItemExample;
import cn.binux.pojo.XbinResult;
import cn.binux.utils.FastJsonConvert;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
package cn.binux.cart.service.impl;
/**
* 购物车操作实现
*
* @author xubin.
* @create 2017-02-22 下午12:51
*/
//@Transactional
@Api(value = "API - CartServiceImpl", description = "购物车操作")
@RestController
@RefreshScope
public class CartServiceImpl implements CartService {
private static final Logger logger = LoggerFactory.getLogger(CartServiceImpl.class);
@Value("${redisKey.prefix.cart_info_profix}")
private String CART_INFO_PROFIX;
@Value("${redisKey.prefix.redis_cart_expire_time}")
private Integer REDIS_CART_EXPIRE_TIME;
@Value("${redisKey.prefix.item_info_profix}")
private String ITEM_INFO_PROFIX;
@Value("${redisKey.prefix.item_info_base_suffix}")
private String ITEM_INFO_BASE_SUFFIX;
@Autowired | private JedisClient jedisClient; |
xubinux/xbin-store-cloud | xbin-store-cloud-web-admin/src/main/java/cn/binux/admin/controller/AdminController.java | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.admin.service.ContentService;
import cn.binux.admin.vo.ManageUserVO;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import java.util.Random; | package cn.binux.admin.controller;
/**
* Admin 首页Controller
*
* @author xubin.
* @create 2017-02-11 下午3:38
*/
@Controller
public class AdminController {
@Autowired | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-web-admin/src/main/java/cn/binux/admin/controller/AdminController.java
import cn.binux.admin.service.ContentService;
import cn.binux.admin.vo.ManageUserVO;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import java.util.Random;
package cn.binux.admin.controller;
/**
* Admin 首页Controller
*
* @author xubin.
* @create 2017-02-11 下午3:38
*/
@Controller
public class AdminController {
@Autowired | private ContentService contentService; |
xubinux/xbin-store-cloud | xbin-store-cloud-web-admin/src/main/java/cn/binux/admin/controller/AdminController.java | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.admin.service.ContentService;
import cn.binux.admin.vo.ManageUserVO;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import java.util.Random; |
model.addAttribute("random", nub);
return "twoCategory";
}
@RequestMapping("/category/getTableData")
public @ResponseBody Map<String, Object> getCategory(Model model, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
Map<String, Object> lists = contentService.getCategoryList(sEcho,iDisplayStart,iDisplayLength);
return lists;
}
@RequestMapping("/category/secondary/getTableData")
public @ResponseBody Map<String, Object> getCategorySecondary(Model model,String sSearch, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
if (StringUtils.isNotBlank(sSearch)) {
try {
sSearch = new String(sSearch.getBytes("iso8859-1"), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Map<String, Object> lists = contentService.getSearchCategorySecondaryList(sSearch,sEcho,iDisplayStart,iDisplayLength);
return lists;
}
Map<String, Object> lists = contentService.getCategorySecondaryList(sEcho,iDisplayStart,iDisplayLength);
return lists;
}
@RequestMapping("/save/category") | // Path: xbin-store-cloud-service-admin-api/src/main/java/cn/binux/admin/service/ContentService.java
// @FeignClient(value = "xbin-store-cloud-service-admin",fallback = ContentServiceHystrix.class)
// public interface ContentService {
//
// @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
// Map<String, Object> getCategoryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/save/category",method = RequestMethod.POST)
// XbinResult saveCategory(
// @RequestParam("id") String id,
// @RequestParam("name") String name,
// @RequestParam("sort_order") Integer sort_order
// );
//
// @RequestMapping(value = "/getCategorySecondary",method = RequestMethod.POST)
// Map<String,Object> getCategorySecondaryList(
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/getSearchCategorySecondaryList",method = RequestMethod.POST)
// Map<String,Object> getSearchCategorySecondaryList(
// @RequestParam("sSearch") String sSearch,
// @RequestParam("sEcho") Integer sEcho,
// @RequestParam("iDisplayStart") Integer iDisplayStart,
// @RequestParam("iDisplayLength") Integer iDisplayLength
// );
//
// @RequestMapping(value = "/saveCategorySecondary",method = RequestMethod.POST)
// XbinResult saveCategorySecondary(TbCategorySecondary categorySecondary);
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-web-admin/src/main/java/cn/binux/admin/controller/AdminController.java
import cn.binux.admin.service.ContentService;
import cn.binux.admin.vo.ManageUserVO;
import cn.binux.pojo.TbCategorySecondary;
import cn.binux.pojo.XbinResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import java.util.Random;
model.addAttribute("random", nub);
return "twoCategory";
}
@RequestMapping("/category/getTableData")
public @ResponseBody Map<String, Object> getCategory(Model model, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
Map<String, Object> lists = contentService.getCategoryList(sEcho,iDisplayStart,iDisplayLength);
return lists;
}
@RequestMapping("/category/secondary/getTableData")
public @ResponseBody Map<String, Object> getCategorySecondary(Model model,String sSearch, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
if (StringUtils.isNotBlank(sSearch)) {
try {
sSearch = new String(sSearch.getBytes("iso8859-1"), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Map<String, Object> lists = contentService.getSearchCategorySecondaryList(sSearch,sEcho,iDisplayStart,iDisplayLength);
return lists;
}
Map<String, Object> lists = contentService.getCategorySecondaryList(sEcho,iDisplayStart,iDisplayLength);
return lists;
}
@RequestMapping("/save/category") | public @ResponseBody XbinResult saveCategory(String id, String name, Integer sort_order) { |
xubinux/xbin-store-cloud | xbin-store-cloud-web-portal/src/main/java/cn/binux/portal/controller/IndexController.java | // Path: xbin-store-cloud-service-portal-api/src/main/java/cn/binux/portal/service/PortalContentService.java
// @FeignClient(value = "xbin-store-cloud-service-portal",fallback = PortalContentServiceHystrix.class)
// public interface PortalContentService {
//
// @RequestMapping(value = "/getContentByCid",method = RequestMethod.POST)
// List<TbContent> getContentByCid(@RequestParam("bigAdIndex") Long bigAdIndex);
// }
| import cn.binux.portal.service.PortalContentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; | package cn.binux.portal.controller;
/**
* 首页 Controller
* @create 2017-05-04
*/
@Api(value = "API - IndexController", description = "首页Controller")
@Controller
@RefreshScope
public class IndexController {
@Autowired | // Path: xbin-store-cloud-service-portal-api/src/main/java/cn/binux/portal/service/PortalContentService.java
// @FeignClient(value = "xbin-store-cloud-service-portal",fallback = PortalContentServiceHystrix.class)
// public interface PortalContentService {
//
// @RequestMapping(value = "/getContentByCid",method = RequestMethod.POST)
// List<TbContent> getContentByCid(@RequestParam("bigAdIndex") Long bigAdIndex);
// }
// Path: xbin-store-cloud-web-portal/src/main/java/cn/binux/portal/controller/IndexController.java
import cn.binux.portal.service.PortalContentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
package cn.binux.portal.controller;
/**
* 首页 Controller
* @create 2017-05-04
*/
@Api(value = "API - IndexController", description = "首页Controller")
@Controller
@RefreshScope
public class IndexController {
@Autowired | private PortalContentService portalContentService; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-search/src/main/java/cn/binux/search/service/impl/SearchServiceImpl.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
// @FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
// public interface SearchService {
//
// //http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @RequestMapping(value = "/importAllItems",method = RequestMethod.POST)
// XbinResult importAllItems();
//
// //http://localhost:8512/search/SolrService/search/查询条件/1/60
// /**
// * 查询商品
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @RequestMapping(value = "/search",method = RequestMethod.POST)
// SearchResult search(
// @RequestParam("q") String queryString,
// @RequestParam(name = "page",defaultValue = "1") Integer page,
// @RequestParam(name = "rows",defaultValue = "0") Integer rows
// );
// }
| import cn.binux.pojo.SearchResult;
import cn.binux.pojo.SolrItem;
import cn.binux.pojo.XbinResult;
import cn.binux.search.mapper.SearchMapper;
import cn.binux.search.service.SearchService;
import io.swagger.annotations.*;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; | package cn.binux.search.service.impl;
/**
* Solr Service 实现类
*
* @author xubin.
* @create 2017-05-03
*/
@RestController
public class SearchServiceImpl implements SearchService {
@Autowired
private SearchMapper searchMapper;
@Autowired
private SolrClient solrClient;
private static Logger logger = LoggerFactory.getLogger(SearchServiceImpl.class);
@Override
@ApiOperation("初始化solr数据 导入全部商品数据")
@ApiResponses(
{
@ApiResponse(code = 200, message = "Successful — 请求已完成"),
@ApiResponse(code = 400, message = "请求中有语法问题,或不能满足请求"),
@ApiResponse(code = 401, message = "未授权客户机访问数据"),
@ApiResponse(code = 404, message = "服务器找不到给定的资源;文档不存在"),
@ApiResponse(code = 500, message = "服务器不能完成请求")
}
) | // Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
// @FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
// public interface SearchService {
//
// //http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @RequestMapping(value = "/importAllItems",method = RequestMethod.POST)
// XbinResult importAllItems();
//
// //http://localhost:8512/search/SolrService/search/查询条件/1/60
// /**
// * 查询商品
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @RequestMapping(value = "/search",method = RequestMethod.POST)
// SearchResult search(
// @RequestParam("q") String queryString,
// @RequestParam(name = "page",defaultValue = "1") Integer page,
// @RequestParam(name = "rows",defaultValue = "0") Integer rows
// );
// }
// Path: xbin-store-cloud-service-search/src/main/java/cn/binux/search/service/impl/SearchServiceImpl.java
import cn.binux.pojo.SearchResult;
import cn.binux.pojo.SolrItem;
import cn.binux.pojo.XbinResult;
import cn.binux.search.mapper.SearchMapper;
import cn.binux.search.service.SearchService;
import io.swagger.annotations.*;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
package cn.binux.search.service.impl;
/**
* Solr Service 实现类
*
* @author xubin.
* @create 2017-05-03
*/
@RestController
public class SearchServiceImpl implements SearchService {
@Autowired
private SearchMapper searchMapper;
@Autowired
private SolrClient solrClient;
private static Logger logger = LoggerFactory.getLogger(SearchServiceImpl.class);
@Override
@ApiOperation("初始化solr数据 导入全部商品数据")
@ApiResponses(
{
@ApiResponse(code = 200, message = "Successful — 请求已完成"),
@ApiResponse(code = 400, message = "请求中有语法问题,或不能满足请求"),
@ApiResponse(code = 401, message = "未授权客户机访问数据"),
@ApiResponse(code = 404, message = "服务器找不到给定的资源;文档不存在"),
@ApiResponse(code = 500, message = "服务器不能完成请求")
}
) | public XbinResult importAllItems() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-portal/src/main/java/cn/binux/XbinStoreServicePortalApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServicePortalApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServicePortalApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-portal/src/main/java/cn/binux/XbinStoreServicePortalApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServicePortalApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServicePortalApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-portal/src/main/java/cn/binux/XbinStoreServicePortalApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServicePortalApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServicePortalApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-portal/src/main/java/cn/binux/XbinStoreServicePortalApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServicePortalApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServicePortalApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
xubinux/xbin-store-cloud | xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/OrderService.java | // Path: xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/hystrix/OrderServiceHystrix.java
// @Component
// public class OrderServiceHystrix implements OrderService {
//
//
// /**
// * 提交订单
// *
// * @param userCookieValue 用户登录Cookie
// * @param cartCookieValue 购物车Cookie
// * @param addrId 用户地址id
// * @param noAnnoyance 运费险
// * @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
// * @param orderId
// * @param shippingName 快递名称 固定顺丰速运 @return
// */
// @Override
// public XbinResult generateOrder(String userCookieValue, String cartCookieValue, Integer addrId, Integer noAnnoyance, Integer paymentType, String orderId, String shippingName) {
// return null;
// }
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
| import cn.binux.order.service.hystrix.OrderServiceHystrix;
import cn.binux.pojo.XbinResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; | package cn.binux.order.service;
/**
* @author xubin.
* @create 2017-02-28 下午9:04
*/
@FeignClient(value = "xbin-store-cloud-service-order",fallback = OrderServiceHystrix.class)
public interface OrderService {
/**
* 提交订单
*
* @param userCookieValue 用户登录Cookie
* @param cartCookieValue 购物车Cookie
* @param addrId 用户地址id
* @param noAnnoyance 运费险
* @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
* @param shippingName 快递名称 固定顺丰速运
* @return
*/
@RequestMapping(value = "/generateOrder",method = RequestMethod.POST) | // Path: xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/hystrix/OrderServiceHystrix.java
// @Component
// public class OrderServiceHystrix implements OrderService {
//
//
// /**
// * 提交订单
// *
// * @param userCookieValue 用户登录Cookie
// * @param cartCookieValue 购物车Cookie
// * @param addrId 用户地址id
// * @param noAnnoyance 运费险
// * @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
// * @param orderId
// * @param shippingName 快递名称 固定顺丰速运 @return
// */
// @Override
// public XbinResult generateOrder(String userCookieValue, String cartCookieValue, Integer addrId, Integer noAnnoyance, Integer paymentType, String orderId, String shippingName) {
// return null;
// }
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
// Path: xbin-store-cloud-service-order-api/src/main/java/cn/binux/order/service/OrderService.java
import cn.binux.order.service.hystrix.OrderServiceHystrix;
import cn.binux.pojo.XbinResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
package cn.binux.order.service;
/**
* @author xubin.
* @create 2017-02-28 下午9:04
*/
@FeignClient(value = "xbin-store-cloud-service-order",fallback = OrderServiceHystrix.class)
public interface OrderService {
/**
* 提交订单
*
* @param userCookieValue 用户登录Cookie
* @param cartCookieValue 购物车Cookie
* @param addrId 用户地址id
* @param noAnnoyance 运费险
* @param paymentType 支付方式 1、货到付款,2、在线支付,3、微信支付,4、支付宝支付
* @param shippingName 快递名称 固定顺丰速运
* @return
*/
@RequestMapping(value = "/generateOrder",method = RequestMethod.POST) | XbinResult generateOrder( |
xubinux/xbin-store-cloud | xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/hystrix/SearchServiceHystrix.java
// @Component
// public class SearchServiceHystrix implements SearchService {
//
//
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @Override
// public XbinResult importAllItems() {
// return null;
// }
//
// /**
// * 查询商品
// *
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @Override
// public SearchResult search(String queryString, Integer page, Integer rows) {
// return null;
// }
// }
| import cn.binux.pojo.SearchResult;
import cn.binux.pojo.XbinResult;
import cn.binux.search.service.hystrix.SearchServiceHystrix;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; | package cn.binux.search.service;
/**
* Solr Service
*
* @author xubin.
* @create 2017-05-03
*/
@FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
public interface SearchService {
//http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
/**
* 导入全部商品索引
*
* @return
*/
@RequestMapping(value = "/importAllItems",method = RequestMethod.POST) | // Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/hystrix/SearchServiceHystrix.java
// @Component
// public class SearchServiceHystrix implements SearchService {
//
//
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @Override
// public XbinResult importAllItems() {
// return null;
// }
//
// /**
// * 查询商品
// *
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @Override
// public SearchResult search(String queryString, Integer page, Integer rows) {
// return null;
// }
// }
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
import cn.binux.pojo.SearchResult;
import cn.binux.pojo.XbinResult;
import cn.binux.search.service.hystrix.SearchServiceHystrix;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
package cn.binux.search.service;
/**
* Solr Service
*
* @author xubin.
* @create 2017-05-03
*/
@FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
public interface SearchService {
//http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
/**
* 导入全部商品索引
*
* @return
*/
@RequestMapping(value = "/importAllItems",method = RequestMethod.POST) | XbinResult importAllItems(); |
xubinux/xbin-store-cloud | xbin-store-cloud-web-sso/src/main/java/cn/binux/sso/controller/AuthImagesController.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
| import cn.binux.sso.utils.VerifyCodeUtils;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; | package cn.binux.sso.controller;
/**
* 验证码 Controller
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - AuthImagesController", description = "验证码 Controller")
@Controller
@RefreshScope
public class AuthImagesController {
private static final Logger logger = LoggerFactory.getLogger(AuthImagesController.class);
@Autowired | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
// Path: xbin-store-cloud-web-sso/src/main/java/cn/binux/sso/controller/AuthImagesController.java
import cn.binux.sso.utils.VerifyCodeUtils;
import cn.binux.utils.JedisClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
package cn.binux.sso.controller;
/**
* 验证码 Controller
*
* @author xubin.
* @create 2017-05-05
*/
@Api(value = "API - AuthImagesController", description = "验证码 Controller")
@Controller
@RefreshScope
public class AuthImagesController {
private static final Logger logger = LoggerFactory.getLogger(AuthImagesController.class);
@Autowired | private JedisClient jedisClient; |
xubinux/xbin-store-cloud | xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/hystrix/SearchServiceHystrix.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
// @FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
// public interface SearchService {
//
// //http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @RequestMapping(value = "/importAllItems",method = RequestMethod.POST)
// XbinResult importAllItems();
//
// //http://localhost:8512/search/SolrService/search/查询条件/1/60
// /**
// * 查询商品
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @RequestMapping(value = "/search",method = RequestMethod.POST)
// SearchResult search(
// @RequestParam("q") String queryString,
// @RequestParam(name = "page",defaultValue = "1") Integer page,
// @RequestParam(name = "rows",defaultValue = "0") Integer rows
// );
// }
| import cn.binux.pojo.SearchResult;
import cn.binux.pojo.XbinResult;
import cn.binux.search.service.SearchService;
import org.springframework.stereotype.Component; | package cn.binux.search.service.hystrix;
/**
* 搜索服务 熔断处理
*
* @author xubin.
* @create 2017-05-03 下午9:19
*/
@Component
public class SearchServiceHystrix implements SearchService {
/**
* 导入全部商品索引
*
* @return
*/
@Override | // Path: xbin-store-cloud-common/src/main/java/cn/binux/pojo/XbinResult.java
// public class XbinResult {
//
// // 响应业务状态
// private Integer status;
//
// // 响应消息
// private String msg;
//
// // 响应中的数据
// private Object data;
//
// public static XbinResult build(Integer status, String msg, Object data) {
// return new XbinResult(status, msg, data);
// }
//
// public static XbinResult ok(Object data) {
// return new XbinResult(data);
// }
//
// public static XbinResult ok() {
// return new XbinResult(null);
// }
//
// public XbinResult() {
//
// }
//
// public static XbinResult build(Integer status, String msg) {
// return new XbinResult(status, msg, null);
// }
//
// public XbinResult(Integer status, String msg, Object data) {
// this.status = status;
// this.msg = msg;
// this.data = data;
// }
//
// public XbinResult(Object data) {
// this.status = 200;
// this.msg = "OK";
// this.data = data;
// }
//
// public Boolean isOK() {
// return this.status == 200;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
// public String getMsg() {
// return msg;
// }
//
// public void setMsg(String msg) {
// this.msg = msg;
// }
//
// public Object getData() {
// return data;
// }
//
// public void setData(Object data) {
// this.data = data;
// }
//
//
//
// }
//
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/SearchService.java
// @FeignClient(value = "xbin-store-cloud-service-search",fallback = SearchServiceHystrix.class)
// public interface SearchService {
//
// //http://localhost:8512/search/SolrService/importAllItems/TztyomXxDyi92
// /**
// * 导入全部商品索引
// *
// * @return
// */
// @RequestMapping(value = "/importAllItems",method = RequestMethod.POST)
// XbinResult importAllItems();
//
// //http://localhost:8512/search/SolrService/search/查询条件/1/60
// /**
// * 查询商品
// * @param queryString 查询条件
// * @param page 第几页
// * @param rows 每页几条
// * @return 返回商品Json
// * @throws Exception
// */
// @RequestMapping(value = "/search",method = RequestMethod.POST)
// SearchResult search(
// @RequestParam("q") String queryString,
// @RequestParam(name = "page",defaultValue = "1") Integer page,
// @RequestParam(name = "rows",defaultValue = "0") Integer rows
// );
// }
// Path: xbin-store-cloud-service-search-api/src/main/java/cn/binux/search/service/hystrix/SearchServiceHystrix.java
import cn.binux.pojo.SearchResult;
import cn.binux.pojo.XbinResult;
import cn.binux.search.service.SearchService;
import org.springframework.stereotype.Component;
package cn.binux.search.service.hystrix;
/**
* 搜索服务 熔断处理
*
* @author xubin.
* @create 2017-05-03 下午9:19
*/
@Component
public class SearchServiceHystrix implements SearchService {
/**
* 导入全部商品索引
*
* @return
*/
@Override | public XbinResult importAllItems() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-order/src/main/java/cn/binux/XbinStoreServiceOrderApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceOrderApplication.class, args);
}
@Bean | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-order/src/main/java/cn/binux/XbinStoreServiceOrderApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceOrderApplication.class, args);
}
@Bean | public JedisClient jedisClient() { |
xubinux/xbin-store-cloud | xbin-store-cloud-service-order/src/main/java/cn/binux/XbinStoreServiceOrderApplication.java | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
| import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; | package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceOrderApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | // Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/JedisClient.java
// public interface JedisClient {
//
// String get(String key);
//
// String set(String key, String value);
//
// String hget(String hkey, String key);
//
// long hset(String hkey, String key, String value);
//
// long incr(String key);
//
// long expire(String key, Integer second);
//
// long ttl(String key);
//
// long del(String key);
//
// long hdel(String hkey, String key);
//
//
// }
//
// Path: xbin-store-cloud-common/src/main/java/cn/binux/utils/impl/JedisClientSingle.java
// public class JedisClientSingle implements JedisClient {
//
// @Autowired
// private JedisPool jedisPool;
//
// @Value("${redis.password}")
// private String password;
//
// private Jedis getResource() {
// Jedis resource = jedisPool.getResource();
// if (StringUtils.isBlank(password)) {
// return resource;
// } else {
// resource.auth(password);
// return resource;
// }
// }
//
// @Override
// public String get(String key) {
//
// Jedis resource = getResource();
//
// String string = resource.get(key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String set(String key, String value) {
//
// Jedis resource = getResource();
//
// String string = resource.set(key, value);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public String hget(String hkey, String key) {
//
// Jedis resource = getResource();
//
// String string = resource.hget(hkey, key);
//
// resource.close();
//
// return string;
//
// }
//
// @Override
// public long hset(String hkey, String key, String value) {
//
// Jedis resource = getResource();
//
// Long hset = resource.hset(hkey, key, value);
//
// resource.close();
//
// return hset;
//
// }
//
// @Override
// public long incr(String key) {
//
// Jedis resource = getResource();
//
// Long incr = resource.incr(key);
//
// resource.close();
//
// return incr;
//
// }
//
// @Override
// public long expire(String key, Integer second) {
//
// Jedis resource = getResource();
//
// Long expire = resource.expire(key, second);
//
// resource.close();
//
// return expire;
//
// }
//
// @Override
// public long ttl(String key) {
//
// Jedis resource = getResource();
//
// Long ttl = resource.ttl(key);
//
// resource.close();
//
// return ttl;
// }
//
// @Override
// public long del(String key) {
//
// Jedis resource = getResource();
//
// Long del = resource.del(key);
//
// resource.close();
//
// return del;
// }
//
// @Override
// public long hdel(String hkey, String key) {
//
// Jedis resource = getResource();
//
// Long hdel = resource.hdel(hkey, key);
//
// resource.close();
//
// return hdel;
// }
// }
// Path: xbin-store-cloud-service-order/src/main/java/cn/binux/XbinStoreServiceOrderApplication.java
import cn.binux.utils.JedisClient;
import cn.binux.utils.impl.JedisClientSingle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package cn.binux;
@EnableHystrix
@Configuration
//@EnableApolloConfig
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan(basePackages = "cn.binux.mapper")
public class XbinStoreServiceOrderApplication {
public static void main(String[] args) {
SpringApplication.run(XbinStoreServiceOrderApplication.class, args);
}
@Bean
public JedisClient jedisClient() { | return new JedisClientSingle(); |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
| import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile; | package dev.codenmore.tilegame.entities.statics;
public class Tree extends StaticEntity {
public Tree(Handler handler, float x, float y) { | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
// Path: Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java
import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.statics;
public class Tree extends StaticEntity {
public Tree(Handler handler, float x, float y) { | super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT * 2); |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
| import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile; | package dev.codenmore.tilegame.entities.statics;
public class Tree extends StaticEntity {
public Tree(Handler handler, float x, float y) {
super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT * 2);
bounds.x = 10;
bounds.y = (int) (height / 1.5f);
bounds.width = width - 20;
bounds.height = (int) (height - height / 1.5f);
}
@Override
public void tick() {
}
@Override
public void die(){
}
@Override
public void render(Graphics g) { | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
// Path: Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java
import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.statics;
public class Tree extends StaticEntity {
public Tree(Handler handler, float x, float y) {
super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT * 2);
bounds.x = 10;
bounds.y = (int) (height / 1.5f);
bounds.width = width - 20;
bounds.height = (int) (height - height / 1.5f);
}
@Override
public void tick() {
}
@Override
public void die(){
}
@Override
public void render(Graphics g) { | g.drawImage(Assets.tree, (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset()), width, height, null); |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Rock.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
| import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile; | package dev.codenmore.tilegame.entities.statics;
public class Rock extends StaticEntity {
public Rock(Handler handler, float x, float y) { | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
// Path: Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Rock.java
import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.statics;
public class Rock extends StaticEntity {
public Rock(Handler handler, float x, float y) { | super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT); |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Rock.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
| import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile; | package dev.codenmore.tilegame.entities.statics;
public class Rock extends StaticEntity {
public Rock(Handler handler, float x, float y) {
super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT);
bounds.x = 3;
bounds.y = (int) (height / 2f);
bounds.width = width - 6;
bounds.height = (int) (height - height / 2f);
}
@Override
public void tick() {
}
@Override
public void die(){
}
@Override
public void render(Graphics g) { | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
// Path: Episode 31/TileGame/src/dev/codenmore/tilegame/entities/statics/Rock.java
import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.statics;
public class Rock extends StaticEntity {
public Rock(Handler handler, float x, float y) {
super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT);
bounds.x = 3;
bounds.y = (int) (height / 2f);
bounds.width = width - 6;
bounds.height = (int) (height - height / 2f);
}
@Override
public void tick() {
}
@Override
public void die(){
}
@Override
public void render(Graphics g) { | g.drawImage(Assets.rock, (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset()), width, height, null); |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 27/TileGame/src/dev/codenmore/tilegame/entities/EntityManager.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/entities/creatures/Player.java
// public class Player extends Creature {
//
// //Animations
// private Animation animDown, animUp, animLeft, animRight;
// // Attack timer
// private long lastAttackTimer, attackCooldown = 800, attackTimer = attackCooldown;
// // Inventory
// private Inventory inventory;
//
// public Player(Handler handler, float x, float y) {
// super(handler, x, y, Creature.DEFAULT_CREATURE_WIDTH, Creature.DEFAULT_CREATURE_HEIGHT);
//
// bounds.x = 22;
// bounds.y = 44;
// bounds.width = 19;
// bounds.height = 19;
//
// //Animatons
// animDown = new Animation(500, Assets.player_down);
// animUp = new Animation(500, Assets.player_up);
// animLeft = new Animation(500, Assets.player_left);
// animRight = new Animation(500, Assets.player_right);
//
// inventory = new Inventory(handler);
// }
//
// @Override
// public void tick() {
// //Animations
// animDown.tick();
// animUp.tick();
// animRight.tick();
// animLeft.tick();
// //Movement
// getInput();
// move();
// handler.getGameCamera().centerOnEntity(this);
// // Attack
// checkAttacks();
// // Inventory
// inventory.tick();
// }
//
// private void checkAttacks(){
// attackTimer += System.currentTimeMillis() - lastAttackTimer;
// lastAttackTimer = System.currentTimeMillis();
// if(attackTimer < attackCooldown)
// return;
//
// if(inventory.isActive())
// return;
//
// Rectangle cb = getCollisionBounds(0, 0);
// Rectangle ar = new Rectangle();
// int arSize = 20;
// ar.width = arSize;
// ar.height = arSize;
//
// if(handler.getKeyManager().aUp){
// ar.x = cb.x + cb.width / 2 - arSize / 2;
// ar.y = cb.y - arSize;
// }else if(handler.getKeyManager().aDown){
// ar.x = cb.x + cb.width / 2 - arSize / 2;
// ar.y = cb.y + cb.height;
// }else if(handler.getKeyManager().aLeft){
// ar.x = cb.x - arSize;
// ar.y = cb.y + cb.height / 2 - arSize / 2;
// }else if(handler.getKeyManager().aRight){
// ar.x = cb.x + cb.width;
// ar.y = cb.y + cb.height / 2 - arSize / 2;
// }else{
// return;
// }
//
// attackTimer = 0;
//
// for(Entity e : handler.getWorld().getEntityManager().getEntities()){
// if(e.equals(this))
// continue;
// if(e.getCollisionBounds(0, 0).intersects(ar)){
// e.hurt(1);
// return;
// }
// }
//
// }
//
// @Override
// public void die(){
// System.out.println("You lose");
// }
//
// private void getInput(){
// xMove = 0;
// yMove = 0;
//
// if(inventory.isActive())
// return;
//
// if(handler.getKeyManager().up)
// yMove = -speed;
// if(handler.getKeyManager().down)
// yMove = speed;
// if(handler.getKeyManager().left)
// xMove = -speed;
// if(handler.getKeyManager().right)
// xMove = speed;
// }
//
// @Override
// public void render(Graphics g) {
// g.drawImage(getCurrentAnimationFrame(), (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset()), width, height, null);
// }
//
// public void postRender(Graphics g){
// inventory.render(g);
// }
//
// private BufferedImage getCurrentAnimationFrame(){
// if(xMove < 0){
// return animLeft.getCurrentFrame();
// }else if(xMove > 0){
// return animRight.getCurrentFrame();
// }else if(yMove < 0){
// return animUp.getCurrentFrame();
// }else{
// return animDown.getCurrentFrame();
// }
// }
//
// public Inventory getInventory() {
// return inventory;
// }
//
// public void setInventory(Inventory inventory) {
// this.inventory = inventory;
// }
//
// }
| import java.awt.Graphics;
import java.util.ArrayList;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.entities.creatures.Player; | package dev.codenmore.tilegame.entities;
public class EntityManager {
private Handler handler; | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/entities/creatures/Player.java
// public class Player extends Creature {
//
// //Animations
// private Animation animDown, animUp, animLeft, animRight;
// // Attack timer
// private long lastAttackTimer, attackCooldown = 800, attackTimer = attackCooldown;
// // Inventory
// private Inventory inventory;
//
// public Player(Handler handler, float x, float y) {
// super(handler, x, y, Creature.DEFAULT_CREATURE_WIDTH, Creature.DEFAULT_CREATURE_HEIGHT);
//
// bounds.x = 22;
// bounds.y = 44;
// bounds.width = 19;
// bounds.height = 19;
//
// //Animatons
// animDown = new Animation(500, Assets.player_down);
// animUp = new Animation(500, Assets.player_up);
// animLeft = new Animation(500, Assets.player_left);
// animRight = new Animation(500, Assets.player_right);
//
// inventory = new Inventory(handler);
// }
//
// @Override
// public void tick() {
// //Animations
// animDown.tick();
// animUp.tick();
// animRight.tick();
// animLeft.tick();
// //Movement
// getInput();
// move();
// handler.getGameCamera().centerOnEntity(this);
// // Attack
// checkAttacks();
// // Inventory
// inventory.tick();
// }
//
// private void checkAttacks(){
// attackTimer += System.currentTimeMillis() - lastAttackTimer;
// lastAttackTimer = System.currentTimeMillis();
// if(attackTimer < attackCooldown)
// return;
//
// if(inventory.isActive())
// return;
//
// Rectangle cb = getCollisionBounds(0, 0);
// Rectangle ar = new Rectangle();
// int arSize = 20;
// ar.width = arSize;
// ar.height = arSize;
//
// if(handler.getKeyManager().aUp){
// ar.x = cb.x + cb.width / 2 - arSize / 2;
// ar.y = cb.y - arSize;
// }else if(handler.getKeyManager().aDown){
// ar.x = cb.x + cb.width / 2 - arSize / 2;
// ar.y = cb.y + cb.height;
// }else if(handler.getKeyManager().aLeft){
// ar.x = cb.x - arSize;
// ar.y = cb.y + cb.height / 2 - arSize / 2;
// }else if(handler.getKeyManager().aRight){
// ar.x = cb.x + cb.width;
// ar.y = cb.y + cb.height / 2 - arSize / 2;
// }else{
// return;
// }
//
// attackTimer = 0;
//
// for(Entity e : handler.getWorld().getEntityManager().getEntities()){
// if(e.equals(this))
// continue;
// if(e.getCollisionBounds(0, 0).intersects(ar)){
// e.hurt(1);
// return;
// }
// }
//
// }
//
// @Override
// public void die(){
// System.out.println("You lose");
// }
//
// private void getInput(){
// xMove = 0;
// yMove = 0;
//
// if(inventory.isActive())
// return;
//
// if(handler.getKeyManager().up)
// yMove = -speed;
// if(handler.getKeyManager().down)
// yMove = speed;
// if(handler.getKeyManager().left)
// xMove = -speed;
// if(handler.getKeyManager().right)
// xMove = speed;
// }
//
// @Override
// public void render(Graphics g) {
// g.drawImage(getCurrentAnimationFrame(), (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset()), width, height, null);
// }
//
// public void postRender(Graphics g){
// inventory.render(g);
// }
//
// private BufferedImage getCurrentAnimationFrame(){
// if(xMove < 0){
// return animLeft.getCurrentFrame();
// }else if(xMove > 0){
// return animRight.getCurrentFrame();
// }else if(yMove < 0){
// return animUp.getCurrentFrame();
// }else{
// return animDown.getCurrentFrame();
// }
// }
//
// public Inventory getInventory() {
// return inventory;
// }
//
// public void setInventory(Inventory inventory) {
// this.inventory = inventory;
// }
//
// }
// Path: Episode 27/TileGame/src/dev/codenmore/tilegame/entities/EntityManager.java
import java.awt.Graphics;
import java.util.ArrayList;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.entities.creatures.Player;
package dev.codenmore.tilegame.entities;
public class EntityManager {
private Handler handler; | private Player player; |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 34/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java
// public abstract class Entity {
//
// protected Handler handler;
// protected float x, y;
// protected int width, height;
// protected Rectangle bounds;
//
// public Entity(Handler handler, float x, float y, int width, int height){
// this.handler = handler;
// this.x = x;
// this.y = y;
// this.width = width;
// this.height = height;
//
// bounds = new Rectangle(0, 0, width, height);
// }
//
// public abstract void tick();
//
// public abstract void render(Graphics g);
//
// public boolean checkEntityCollisions(float xOffset, float yOffset){
// for(Entity e : handler.getWorld().getEntityManager().getEntities()){
// if(e.equals(this))
// continue;
// if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset)))
// return true;
// }
// return false;
// }
//
// public Rectangle getCollisionBounds(float xOffset, float yOffset){
// return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height);
// }
//
// public float getX() {
// return x;
// }
//
// public void setX(float x) {
// this.x = x;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float y) {
// this.y = y;
// }
//
// public int getWidth() {
// return width;
// }
//
// public void setWidth(int width) {
// this.width = width;
// }
//
// public int getHeight() {
// return height;
// }
//
// public void setHeight(int height) {
// this.height = height;
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
| import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.entities.Entity;
import dev.codenmore.tilegame.tiles.Tile; | package dev.codenmore.tilegame.entities.creatures;
public abstract class Creature extends Entity {
public static final float DEFAULT_SPEED = 3.0f;
public static final int DEFAULT_CREATURE_WIDTH = 64,
DEFAULT_CREATURE_HEIGHT = 64;
protected float speed;
protected float xMove, yMove;
| // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java
// public abstract class Entity {
//
// protected Handler handler;
// protected float x, y;
// protected int width, height;
// protected Rectangle bounds;
//
// public Entity(Handler handler, float x, float y, int width, int height){
// this.handler = handler;
// this.x = x;
// this.y = y;
// this.width = width;
// this.height = height;
//
// bounds = new Rectangle(0, 0, width, height);
// }
//
// public abstract void tick();
//
// public abstract void render(Graphics g);
//
// public boolean checkEntityCollisions(float xOffset, float yOffset){
// for(Entity e : handler.getWorld().getEntityManager().getEntities()){
// if(e.equals(this))
// continue;
// if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset)))
// return true;
// }
// return false;
// }
//
// public Rectangle getCollisionBounds(float xOffset, float yOffset){
// return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height);
// }
//
// public float getX() {
// return x;
// }
//
// public void setX(float x) {
// this.x = x;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float y) {
// this.y = y;
// }
//
// public int getWidth() {
// return width;
// }
//
// public void setWidth(int width) {
// this.width = width;
// }
//
// public int getHeight() {
// return height;
// }
//
// public void setHeight(int height) {
// this.height = height;
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.entities.Entity;
import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.creatures;
public abstract class Creature extends Entity {
public static final float DEFAULT_SPEED = 3.0f;
public static final int DEFAULT_CREATURE_WIDTH = 64,
DEFAULT_CREATURE_HEIGHT = 64;
protected float speed;
protected float xMove, yMove;
| public Creature(Handler handler, float x, float y, int width, int height) { |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 34/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java
// public abstract class Entity {
//
// protected Handler handler;
// protected float x, y;
// protected int width, height;
// protected Rectangle bounds;
//
// public Entity(Handler handler, float x, float y, int width, int height){
// this.handler = handler;
// this.x = x;
// this.y = y;
// this.width = width;
// this.height = height;
//
// bounds = new Rectangle(0, 0, width, height);
// }
//
// public abstract void tick();
//
// public abstract void render(Graphics g);
//
// public boolean checkEntityCollisions(float xOffset, float yOffset){
// for(Entity e : handler.getWorld().getEntityManager().getEntities()){
// if(e.equals(this))
// continue;
// if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset)))
// return true;
// }
// return false;
// }
//
// public Rectangle getCollisionBounds(float xOffset, float yOffset){
// return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height);
// }
//
// public float getX() {
// return x;
// }
//
// public void setX(float x) {
// this.x = x;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float y) {
// this.y = y;
// }
//
// public int getWidth() {
// return width;
// }
//
// public void setWidth(int width) {
// this.width = width;
// }
//
// public int getHeight() {
// return height;
// }
//
// public void setHeight(int height) {
// this.height = height;
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
| import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.entities.Entity;
import dev.codenmore.tilegame.tiles.Tile; | package dev.codenmore.tilegame.entities.creatures;
public abstract class Creature extends Entity {
public static final float DEFAULT_SPEED = 3.0f;
public static final int DEFAULT_CREATURE_WIDTH = 64,
DEFAULT_CREATURE_HEIGHT = 64;
protected float speed;
protected float xMove, yMove;
public Creature(Handler handler, float x, float y, int width, int height) {
super(handler, x, y, width, height);
speed = DEFAULT_SPEED;
xMove = 0;
yMove = 0;
}
public void move(){
if(!checkEntityCollisions(xMove, 0f))
moveX();
if(!checkEntityCollisions(0f, yMove))
moveY();
}
public void moveX(){
if(xMove > 0){//Moving right | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java
// public abstract class Entity {
//
// protected Handler handler;
// protected float x, y;
// protected int width, height;
// protected Rectangle bounds;
//
// public Entity(Handler handler, float x, float y, int width, int height){
// this.handler = handler;
// this.x = x;
// this.y = y;
// this.width = width;
// this.height = height;
//
// bounds = new Rectangle(0, 0, width, height);
// }
//
// public abstract void tick();
//
// public abstract void render(Graphics g);
//
// public boolean checkEntityCollisions(float xOffset, float yOffset){
// for(Entity e : handler.getWorld().getEntityManager().getEntities()){
// if(e.equals(this))
// continue;
// if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset)))
// return true;
// }
// return false;
// }
//
// public Rectangle getCollisionBounds(float xOffset, float yOffset){
// return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height);
// }
//
// public float getX() {
// return x;
// }
//
// public void setX(float x) {
// this.x = x;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float y) {
// this.y = y;
// }
//
// public int getWidth() {
// return width;
// }
//
// public void setWidth(int width) {
// this.width = width;
// }
//
// public int getHeight() {
// return height;
// }
//
// public void setHeight(int height) {
// this.height = height;
// }
//
// }
//
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java
// public class Tile {
//
// //STATIC STUFF HERE
//
// public static Tile[] tiles = new Tile[256];
// public static Tile grassTile = new GrassTile(0);
// public static Tile dirtTile = new DirtTile(1);
// public static Tile rockTile = new RockTile(2);
//
// //CLASS
//
// public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
//
// protected BufferedImage texture;
// protected final int id;
//
// public Tile(BufferedImage texture, int id){
// this.texture = texture;
// this.id = id;
//
// tiles[id] = this;
// }
//
// public void tick(){
//
// }
//
// public void render(Graphics g, int x, int y){
// g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
// }
//
// public boolean isSolid(){
// return false;
// }
//
// public int getId(){
// return id;
// }
//
// }
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.entities.Entity;
import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.creatures;
public abstract class Creature extends Entity {
public static final float DEFAULT_SPEED = 3.0f;
public static final int DEFAULT_CREATURE_WIDTH = 64,
DEFAULT_CREATURE_HEIGHT = 64;
protected float speed;
protected float xMove, yMove;
public Creature(Handler handler, float x, float y, int width, int height) {
super(handler, x, y, width, height);
speed = DEFAULT_SPEED;
xMove = 0;
yMove = 0;
}
public void move(){
if(!checkEntityCollisions(xMove, 0f))
moveX();
if(!checkEntityCollisions(0f, yMove))
moveY();
}
public void moveX(){
if(xMove > 0){//Moving right | int tx = (int) (x + xMove + bounds.x + bounds.width) / Tile.TILEWIDTH; |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 34/TileGame/src/dev/codenmore/tilegame/states/State.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
| import java.awt.Graphics;
import dev.codenmore.tilegame.Handler; | package dev.codenmore.tilegame.states;
public abstract class State {
private static State currentState = null;
public static void setState(State state){
currentState = state;
}
public static State getState(){
return currentState;
}
//CLASS
| // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/states/State.java
import java.awt.Graphics;
import dev.codenmore.tilegame.Handler;
package dev.codenmore.tilegame.states;
public abstract class State {
private static State currentState = null;
public static void setState(State state){
currentState = state;
}
public static State getState(){
return currentState;
}
//CLASS
| protected Handler handler; |
CodeNMore/New-Beginner-Java-Game-Programming-Src | Episode 33/TileGame/src/dev/codenmore/tilegame/items/Item.java | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
| import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets; | package dev.codenmore.tilegame.items;
public class Item {
// Handler
public static Item[] items = new Item[256]; | // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java
// public class Handler {
//
// private Game game;
// private World world;
//
// public Handler(Game game){
// this.game = game;
// }
//
// public GameCamera getGameCamera(){
// return game.getGameCamera();
// }
//
// public KeyManager getKeyManager(){
// return game.getKeyManager();
// }
//
// public MouseManager getMouseManager(){
// return game.getMouseManager();
// }
//
// public int getWidth(){
// return game.getWidth();
// }
//
// public int getHeight(){
// return game.getHeight();
// }
//
// public Game getGame() {
// return game;
// }
//
// public void setGame(Game game) {
// this.game = game;
// }
//
// public World getWorld() {
// return world;
// }
//
// public void setWorld(World world) {
// this.world = world;
// }
//
// }
//
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java
// public class Assets {
//
// private static final int width = 32, height = 32;
//
// public static BufferedImage dirt, grass, stone, tree, rock;
// public static BufferedImage[] player_down, player_up, player_left, player_right;
// public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right;
//
// public static void init(){
// SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));
//
// player_down = new BufferedImage[2];
// player_up = new BufferedImage[2];
// player_left = new BufferedImage[2];
// player_right = new BufferedImage[2];
//
// player_down[0] = sheet.crop(width * 4, 0, width, height);
// player_down[1] = sheet.crop(width * 5, 0, width, height);
// player_up[0] = sheet.crop(width * 6, 0, width, height);
// player_up[1] = sheet.crop(width * 7, 0, width, height);
// player_right[0] = sheet.crop(width * 4, height, width, height);
// player_right[1] = sheet.crop(width * 5, height, width, height);
// player_left[0] = sheet.crop(width * 6, height, width, height);
// player_left[1] = sheet.crop(width * 7, height, width, height);
//
// zombie_down = new BufferedImage[2];
// zombie_up = new BufferedImage[2];
// zombie_left = new BufferedImage[2];
// zombie_right = new BufferedImage[2];
//
// zombie_down[0] = sheet.crop(width * 4, height * 2, width, height);
// zombie_down[1] = sheet.crop(width * 5, height * 2, width, height);
// zombie_up[0] = sheet.crop(width * 6, height * 2, width, height);
// zombie_up[1] = sheet.crop(width * 7, height * 2, width, height);
// zombie_right[0] = sheet.crop(width * 4, height * 3, width, height);
// zombie_right[1] = sheet.crop(width * 5, height * 3, width, height);
// zombie_left[0] = sheet.crop(width * 6, height * 3, width, height);
// zombie_left[1] = sheet.crop(width * 7, height * 3, width, height);
//
// dirt = sheet.crop(width, 0, width, height);
// grass = sheet.crop(width * 2, 0, width, height);
// stone = sheet.crop(width * 3, 0, width, height);
// tree = sheet.crop(0, 0, width, height * 2);
// rock = sheet.crop(0, height * 2, width, height);
// }
//
// }
// Path: Episode 33/TileGame/src/dev/codenmore/tilegame/items/Item.java
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import dev.codenmore.tilegame.Handler;
import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.items;
public class Item {
// Handler
public static Item[] items = new Item[256]; | public static Item woodItem = new Item(Assets.wood, "Wood", 0); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.