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 |
|---|---|---|---|---|---|---|
sptz45/circuit-breaker | src/main/java/com/tzavellas/circuitbreaker/support/CircuitJmxRegistrar.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreaker.java
// public class CircuitBreaker implements CircuitBreakerMBean{
//
// private final CircuitBreakerAspectSupport breaker;
// private final CircuitInfo info;
//
// public CircuitBreaker(CircuitBreakerAspectSupport breaker) {
// this.breaker = breaker;
// info = breaker.getCircuitInfo();
// }
//
// /** {@inheritDoc} */
// public int getCalls() {
// return info.getCalls();
// }
//
// /** {@inheritDoc} */
// public int getCurrentFailures() {
// return info.getCurrentFailures();
// }
//
// /** {@inheritDoc} */
// public String getCurrentFailuresDuration() {
// return nullSafeToString(info.getCurrentFailuresDuration());
// }
//
// /** {@inheritDoc} */
// public String getMaxMethodDuration() {
// return nullSafeToString(breaker.getMaxMethodDuration());
// }
//
// /** {@inheritDoc} */
// public int getFailures() {
// return info.getFailures();
// }
//
// /** {@inheritDoc} */
// public int getMaxFailures() {
// return info.getMaxFailures();
// }
//
// /** {@inheritDoc} */
// public Date getOpenTimestamp() {
// return info.getOpenTimestamp();
// }
//
// /** {@inheritDoc} */
// public String getTimeout() {
// return nullSafeToString(info.getTimeout());
// }
//
// /** {@inheritDoc} */
// public int getTimesOpened() {
// return info.getTimesOpened();
// }
//
// /** {@inheritDoc} */
// public boolean isOpen() {
// return info.isOpen();
// }
//
// /** {@inheritDoc} */
// public void open() {
// info.open();
// }
//
// /** {@inheritDoc} */
// public void setCurrentFailuresDuration(String duration) {
// info.setCurrentFailuresDuration(Duration.valueOf(duration));
// }
//
// /** {@inheritDoc} */
// public void setMaxMethodDuration(String duration) {
// Duration d = null;
// if (duration != null)
// d = Duration.valueOf(duration);
// breaker.setMaxMethodDuration(d);
// }
//
// /** {@inheritDoc} */
// public void setMaxFailures(int maxFailures) {
// info.setMaxFailures(maxFailures);
// }
//
// /** {@inheritDoc} */
// public void setTimeout(String timeout) {
// info.setTimeout(Duration.valueOf(timeout));
// }
//
// /** {@inheritDoc} */
// public void close() {
// info.close();
// }
//
// /** {@inheritDoc} */
// public boolean isClosed() {
// return info.isClosed();
// }
//
// /** {@inheritDoc} */
// public boolean isHalfOpen() {
// return info.isHalfOpen();
// }
//
// private String nullSafeToString(Object o) {
// return o == null? "": o.toString();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
| import java.lang.management.ManagementFactory;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import com.tzavellas.circuitbreaker.jmx.CircuitBreaker;
import com.tzavellas.circuitbreaker.jmx.JmxUtils; | package com.tzavellas.circuitbreaker.support;
/**
* A class that knows how to register and unregister {@code CircuitBreaker}
* objects in JMX.
*
* @see CircuitBreakerAspectSupport
* @see JmxUtils
* @author spiros
*/
class CircuitJmxRegistrar {
private final ObjectName name; | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreaker.java
// public class CircuitBreaker implements CircuitBreakerMBean{
//
// private final CircuitBreakerAspectSupport breaker;
// private final CircuitInfo info;
//
// public CircuitBreaker(CircuitBreakerAspectSupport breaker) {
// this.breaker = breaker;
// info = breaker.getCircuitInfo();
// }
//
// /** {@inheritDoc} */
// public int getCalls() {
// return info.getCalls();
// }
//
// /** {@inheritDoc} */
// public int getCurrentFailures() {
// return info.getCurrentFailures();
// }
//
// /** {@inheritDoc} */
// public String getCurrentFailuresDuration() {
// return nullSafeToString(info.getCurrentFailuresDuration());
// }
//
// /** {@inheritDoc} */
// public String getMaxMethodDuration() {
// return nullSafeToString(breaker.getMaxMethodDuration());
// }
//
// /** {@inheritDoc} */
// public int getFailures() {
// return info.getFailures();
// }
//
// /** {@inheritDoc} */
// public int getMaxFailures() {
// return info.getMaxFailures();
// }
//
// /** {@inheritDoc} */
// public Date getOpenTimestamp() {
// return info.getOpenTimestamp();
// }
//
// /** {@inheritDoc} */
// public String getTimeout() {
// return nullSafeToString(info.getTimeout());
// }
//
// /** {@inheritDoc} */
// public int getTimesOpened() {
// return info.getTimesOpened();
// }
//
// /** {@inheritDoc} */
// public boolean isOpen() {
// return info.isOpen();
// }
//
// /** {@inheritDoc} */
// public void open() {
// info.open();
// }
//
// /** {@inheritDoc} */
// public void setCurrentFailuresDuration(String duration) {
// info.setCurrentFailuresDuration(Duration.valueOf(duration));
// }
//
// /** {@inheritDoc} */
// public void setMaxMethodDuration(String duration) {
// Duration d = null;
// if (duration != null)
// d = Duration.valueOf(duration);
// breaker.setMaxMethodDuration(d);
// }
//
// /** {@inheritDoc} */
// public void setMaxFailures(int maxFailures) {
// info.setMaxFailures(maxFailures);
// }
//
// /** {@inheritDoc} */
// public void setTimeout(String timeout) {
// info.setTimeout(Duration.valueOf(timeout));
// }
//
// /** {@inheritDoc} */
// public void close() {
// info.close();
// }
//
// /** {@inheritDoc} */
// public boolean isClosed() {
// return info.isClosed();
// }
//
// /** {@inheritDoc} */
// public boolean isHalfOpen() {
// return info.isHalfOpen();
// }
//
// private String nullSafeToString(Object o) {
// return o == null? "": o.toString();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
// Path: src/main/java/com/tzavellas/circuitbreaker/support/CircuitJmxRegistrar.java
import java.lang.management.ManagementFactory;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import com.tzavellas.circuitbreaker.jmx.CircuitBreaker;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
package com.tzavellas.circuitbreaker.support;
/**
* A class that knows how to register and unregister {@code CircuitBreaker}
* objects in JMX.
*
* @see CircuitBreakerAspectSupport
* @see JmxUtils
* @author spiros
*/
class CircuitJmxRegistrar {
private final ObjectName name; | private final CircuitBreaker jmxBreaker; |
sptz45/circuit-breaker | src/main/java/com/tzavellas/circuitbreaker/support/CircuitJmxRegistrar.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreaker.java
// public class CircuitBreaker implements CircuitBreakerMBean{
//
// private final CircuitBreakerAspectSupport breaker;
// private final CircuitInfo info;
//
// public CircuitBreaker(CircuitBreakerAspectSupport breaker) {
// this.breaker = breaker;
// info = breaker.getCircuitInfo();
// }
//
// /** {@inheritDoc} */
// public int getCalls() {
// return info.getCalls();
// }
//
// /** {@inheritDoc} */
// public int getCurrentFailures() {
// return info.getCurrentFailures();
// }
//
// /** {@inheritDoc} */
// public String getCurrentFailuresDuration() {
// return nullSafeToString(info.getCurrentFailuresDuration());
// }
//
// /** {@inheritDoc} */
// public String getMaxMethodDuration() {
// return nullSafeToString(breaker.getMaxMethodDuration());
// }
//
// /** {@inheritDoc} */
// public int getFailures() {
// return info.getFailures();
// }
//
// /** {@inheritDoc} */
// public int getMaxFailures() {
// return info.getMaxFailures();
// }
//
// /** {@inheritDoc} */
// public Date getOpenTimestamp() {
// return info.getOpenTimestamp();
// }
//
// /** {@inheritDoc} */
// public String getTimeout() {
// return nullSafeToString(info.getTimeout());
// }
//
// /** {@inheritDoc} */
// public int getTimesOpened() {
// return info.getTimesOpened();
// }
//
// /** {@inheritDoc} */
// public boolean isOpen() {
// return info.isOpen();
// }
//
// /** {@inheritDoc} */
// public void open() {
// info.open();
// }
//
// /** {@inheritDoc} */
// public void setCurrentFailuresDuration(String duration) {
// info.setCurrentFailuresDuration(Duration.valueOf(duration));
// }
//
// /** {@inheritDoc} */
// public void setMaxMethodDuration(String duration) {
// Duration d = null;
// if (duration != null)
// d = Duration.valueOf(duration);
// breaker.setMaxMethodDuration(d);
// }
//
// /** {@inheritDoc} */
// public void setMaxFailures(int maxFailures) {
// info.setMaxFailures(maxFailures);
// }
//
// /** {@inheritDoc} */
// public void setTimeout(String timeout) {
// info.setTimeout(Duration.valueOf(timeout));
// }
//
// /** {@inheritDoc} */
// public void close() {
// info.close();
// }
//
// /** {@inheritDoc} */
// public boolean isClosed() {
// return info.isClosed();
// }
//
// /** {@inheritDoc} */
// public boolean isHalfOpen() {
// return info.isHalfOpen();
// }
//
// private String nullSafeToString(Object o) {
// return o == null? "": o.toString();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
| import java.lang.management.ManagementFactory;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import com.tzavellas.circuitbreaker.jmx.CircuitBreaker;
import com.tzavellas.circuitbreaker.jmx.JmxUtils; | package com.tzavellas.circuitbreaker.support;
/**
* A class that knows how to register and unregister {@code CircuitBreaker}
* objects in JMX.
*
* @see CircuitBreakerAspectSupport
* @see JmxUtils
* @author spiros
*/
class CircuitJmxRegistrar {
private final ObjectName name;
private final CircuitBreaker jmxBreaker;
private volatile boolean registered = false;
CircuitJmxRegistrar(CircuitBreakerAspectSupport breaker, Object target) {
jmxBreaker = new CircuitBreaker(breaker);
try { | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreaker.java
// public class CircuitBreaker implements CircuitBreakerMBean{
//
// private final CircuitBreakerAspectSupport breaker;
// private final CircuitInfo info;
//
// public CircuitBreaker(CircuitBreakerAspectSupport breaker) {
// this.breaker = breaker;
// info = breaker.getCircuitInfo();
// }
//
// /** {@inheritDoc} */
// public int getCalls() {
// return info.getCalls();
// }
//
// /** {@inheritDoc} */
// public int getCurrentFailures() {
// return info.getCurrentFailures();
// }
//
// /** {@inheritDoc} */
// public String getCurrentFailuresDuration() {
// return nullSafeToString(info.getCurrentFailuresDuration());
// }
//
// /** {@inheritDoc} */
// public String getMaxMethodDuration() {
// return nullSafeToString(breaker.getMaxMethodDuration());
// }
//
// /** {@inheritDoc} */
// public int getFailures() {
// return info.getFailures();
// }
//
// /** {@inheritDoc} */
// public int getMaxFailures() {
// return info.getMaxFailures();
// }
//
// /** {@inheritDoc} */
// public Date getOpenTimestamp() {
// return info.getOpenTimestamp();
// }
//
// /** {@inheritDoc} */
// public String getTimeout() {
// return nullSafeToString(info.getTimeout());
// }
//
// /** {@inheritDoc} */
// public int getTimesOpened() {
// return info.getTimesOpened();
// }
//
// /** {@inheritDoc} */
// public boolean isOpen() {
// return info.isOpen();
// }
//
// /** {@inheritDoc} */
// public void open() {
// info.open();
// }
//
// /** {@inheritDoc} */
// public void setCurrentFailuresDuration(String duration) {
// info.setCurrentFailuresDuration(Duration.valueOf(duration));
// }
//
// /** {@inheritDoc} */
// public void setMaxMethodDuration(String duration) {
// Duration d = null;
// if (duration != null)
// d = Duration.valueOf(duration);
// breaker.setMaxMethodDuration(d);
// }
//
// /** {@inheritDoc} */
// public void setMaxFailures(int maxFailures) {
// info.setMaxFailures(maxFailures);
// }
//
// /** {@inheritDoc} */
// public void setTimeout(String timeout) {
// info.setTimeout(Duration.valueOf(timeout));
// }
//
// /** {@inheritDoc} */
// public void close() {
// info.close();
// }
//
// /** {@inheritDoc} */
// public boolean isClosed() {
// return info.isClosed();
// }
//
// /** {@inheritDoc} */
// public boolean isHalfOpen() {
// return info.isHalfOpen();
// }
//
// private String nullSafeToString(Object o) {
// return o == null? "": o.toString();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
// Path: src/main/java/com/tzavellas/circuitbreaker/support/CircuitJmxRegistrar.java
import java.lang.management.ManagementFactory;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import com.tzavellas.circuitbreaker.jmx.CircuitBreaker;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
package com.tzavellas.circuitbreaker.support;
/**
* A class that knows how to register and unregister {@code CircuitBreaker}
* objects in JMX.
*
* @see CircuitBreakerAspectSupport
* @see JmxUtils
* @author spiros
*/
class CircuitJmxRegistrar {
private final ObjectName name;
private final CircuitBreaker jmxBreaker;
private volatile boolean registered = false;
CircuitJmxRegistrar(CircuitBreakerAspectSupport breaker, Object target) {
jmxBreaker = new CircuitBreaker(breaker);
try { | name = new ObjectName(JmxUtils.getObjectName(target)); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/aspectj/CircuitBreakerTest.java | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractCircuitBreakerTest.java
// public abstract class AbstractCircuitBreakerTest {
//
// protected IStockService stocks;
// protected CircuitBreakerAspectSupport stocksBreaker;
//
// @Before
// public void resetCircuit() {
// // this is needed because in Spring the service and the aspect are singletons.
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.close();
// circuit.resetToDefaultConfig();
// circuit.resetStatistics();
// }
//
// @Test
// public void normal_operation_while_closed() {
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test(expected=OpenCircuitException.class)
// public void after_a_number_of_faults_the_circuit_opens() {
// generateFaultsToOpen();
// stocks.getQuote("JAVA");
// }
//
// @Test
// public void the_circuit_can_be_opened_after_being_closed() {
// generateFaultsToOpen();
// try {
// stocks.getQuote("JAVA");
// } catch (OpenCircuitException e) {
// CircuitInfo c = e.getCircuit();
// assertTrue(c.isOpen());
// c.close();
// assertFalse(c.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// return;
// }
// fail("Should have raised an OpenCircuitException");
// }
//
// @Test
// public void the_circuit_is_half_open_after_the_timeout() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// assertEquals(0, circuit.getCurrentFailures());
// }
//
// @Test
// public void the_circuit_moves_from_half_open_to_open_on_first_failure() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// try { stocks.faultyGetQuote("JAVA"); } catch (RuntimeException expected) { }
// assertTrue(circuit.isOpen());
// }
//
// @Test
// public void the_failure_count_gets_reset_after_an_amount_of_time() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.millis(1));
//
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES - 1);
// assertFalse(circuit.isOpen());
// Thread.sleep(5);
//
// generateFaults(1);
// assertFalse(circuit.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test
// public void almost_instant_failure_count_reset() {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.nanos(1));
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(circuit.isOpen());
// }
//
// @Test
// public void ignored_exceptions_do_not_open_a_circuit() {
// stocksBreaker.ignoreException(ArithmeticException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(ArithmeticException.class);
// }
//
// @Test
// public void ignored_exceptions_capture_subclasses() {
// stocksBreaker.ignoreException(RuntimeException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(RuntimeException.class);
// }
//
// @Test
// public void slow_metnod_executions_count_as_failures() {
// stocksBreaker.setMaxMethodDuration(Duration.nanos(1));
// for (int i = 0; i < CircuitInfo.DEFAULT_MAX_FAILURES; i++)
// stocks.getQuote("JAVA");
// assertTrue(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.setMaxMethodDuration(null);
// }
//
//
// //------------------------------------------------------------------------
//
// protected void generateFaultsToOpen() {
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES);
// }
//
// protected void generateFaults(int numOfFaults) {
// for (int i = 0; i < numOfFaults; i++) {
// try { stocks.faultyGetQuote("JAVA"); } catch (ArithmeticException expected) { }
// }
// }
// }
//
// Path: src/test/java/com/tzavellas/test/aj/StockService.java
// public class StockService implements IStockService {
//
// public int getQuote(String ticker) {
// return 5;
// }
//
// public int faultyGetQuote(String ticker) {
// throw new ArithmeticException();
// }
// }
| import com.tzavellas.circuitbreaker.AbstractCircuitBreakerTest;
import com.tzavellas.test.aj.StockService; | package com.tzavellas.circuitbreaker.aspectj;
public class CircuitBreakerTest extends AbstractCircuitBreakerTest {
public CircuitBreakerTest() { | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractCircuitBreakerTest.java
// public abstract class AbstractCircuitBreakerTest {
//
// protected IStockService stocks;
// protected CircuitBreakerAspectSupport stocksBreaker;
//
// @Before
// public void resetCircuit() {
// // this is needed because in Spring the service and the aspect are singletons.
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.close();
// circuit.resetToDefaultConfig();
// circuit.resetStatistics();
// }
//
// @Test
// public void normal_operation_while_closed() {
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test(expected=OpenCircuitException.class)
// public void after_a_number_of_faults_the_circuit_opens() {
// generateFaultsToOpen();
// stocks.getQuote("JAVA");
// }
//
// @Test
// public void the_circuit_can_be_opened_after_being_closed() {
// generateFaultsToOpen();
// try {
// stocks.getQuote("JAVA");
// } catch (OpenCircuitException e) {
// CircuitInfo c = e.getCircuit();
// assertTrue(c.isOpen());
// c.close();
// assertFalse(c.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// return;
// }
// fail("Should have raised an OpenCircuitException");
// }
//
// @Test
// public void the_circuit_is_half_open_after_the_timeout() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// assertEquals(0, circuit.getCurrentFailures());
// }
//
// @Test
// public void the_circuit_moves_from_half_open_to_open_on_first_failure() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// try { stocks.faultyGetQuote("JAVA"); } catch (RuntimeException expected) { }
// assertTrue(circuit.isOpen());
// }
//
// @Test
// public void the_failure_count_gets_reset_after_an_amount_of_time() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.millis(1));
//
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES - 1);
// assertFalse(circuit.isOpen());
// Thread.sleep(5);
//
// generateFaults(1);
// assertFalse(circuit.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test
// public void almost_instant_failure_count_reset() {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.nanos(1));
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(circuit.isOpen());
// }
//
// @Test
// public void ignored_exceptions_do_not_open_a_circuit() {
// stocksBreaker.ignoreException(ArithmeticException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(ArithmeticException.class);
// }
//
// @Test
// public void ignored_exceptions_capture_subclasses() {
// stocksBreaker.ignoreException(RuntimeException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(RuntimeException.class);
// }
//
// @Test
// public void slow_metnod_executions_count_as_failures() {
// stocksBreaker.setMaxMethodDuration(Duration.nanos(1));
// for (int i = 0; i < CircuitInfo.DEFAULT_MAX_FAILURES; i++)
// stocks.getQuote("JAVA");
// assertTrue(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.setMaxMethodDuration(null);
// }
//
//
// //------------------------------------------------------------------------
//
// protected void generateFaultsToOpen() {
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES);
// }
//
// protected void generateFaults(int numOfFaults) {
// for (int i = 0; i < numOfFaults; i++) {
// try { stocks.faultyGetQuote("JAVA"); } catch (ArithmeticException expected) { }
// }
// }
// }
//
// Path: src/test/java/com/tzavellas/test/aj/StockService.java
// public class StockService implements IStockService {
//
// public int getQuote(String ticker) {
// return 5;
// }
//
// public int faultyGetQuote(String ticker) {
// throw new ArithmeticException();
// }
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/aspectj/CircuitBreakerTest.java
import com.tzavellas.circuitbreaker.AbstractCircuitBreakerTest;
import com.tzavellas.test.aj.StockService;
package com.tzavellas.circuitbreaker.aspectj;
public class CircuitBreakerTest extends AbstractCircuitBreakerTest {
public CircuitBreakerTest() { | stocks = new StockService(); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/util/DurationTest.java | // Path: src/main/java/com/tzavellas/circuitbreaker/util/Duration.java
// public final class Duration {
//
// /** A {@code PropertyEditor} for {@code Duration} objects. */
// public static class Editor extends PropertyEditorSupport {
// /** {@inheritDoc} */
// public String getAsText() {
// return getValue().toString();
// }
// /** {@inheritDoc} */
// public void setAsText(String text) throws IllegalArgumentException {
// setValue(Duration.valueOf(text));
// }
// }
//
//
// // -----------------------------------------------------------------------
//
// private final long duration;
// private final TimeUnit unit;
//
// public Duration(long duration, TimeUnit unit) {
// this.duration = duration;
// this.unit = unit;
// }
//
// public boolean hasPastSince(long nanos) {
// long now = System.nanoTime();
// return now - nanos >= toNanos();
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj instanceof Duration) {
// Duration that = (Duration) obj;
// return this.toNanos() == that.toNanos();
// }
// return false;
// }
//
// @Override
// public int hashCode() {
// return 37 * Long.valueOf(toNanos()).hashCode() * TimeUnit.NANOSECONDS.hashCode();
// }
//
// @Override
// public String toString() {
// String unitString = null;
// switch (unit) {
// case NANOSECONDS: unitString = "ns"; break;
// case MICROSECONDS: unitString = "us"; break;
// case MILLISECONDS: unitString = "ms"; break;
// case SECONDS: unitString = "s"; break;
// case MINUTES: unitString = "m"; break;
// case HOURS: unitString = "h"; break;
// case DAYS: unitString = "d"; break;
// default:
// throw new AssertionError();
// }
// return duration + unitString;
// }
//
// public static Duration valueOf(String durationAsString) {
// try {
// Scanner s = new Scanner(durationAsString);
// s.findInLine("(\\d+)[\\s]*([μ]*\\w+)");
// MatchResult result = s.match();
// long duration = Long.valueOf(result.group(1));
// String us = result.group(2);
// TimeUnit unit = null;
// // order is important cause we have 2 matches for startsWith("m"): "m" an "ms"
// if (us.startsWith("d")) unit = TimeUnit.DAYS;
// if (us.startsWith("h")) unit = TimeUnit.HOURS;
// if (us.startsWith("m")) unit = TimeUnit.MINUTES;
// if (us.startsWith("s")) unit = TimeUnit.SECONDS;
// if (us.startsWith("ms")) unit = TimeUnit.MILLISECONDS;
// if (us.startsWith("us")) unit = TimeUnit.MICROSECONDS;
// if (us.startsWith("ns")) unit = TimeUnit.NANOSECONDS;
// if (unit == null) throw new NullPointerException();
//
// return new Duration(duration, unit);
// } catch (RuntimeException e) {
// throw new IllegalArgumentException("Could not parse [" + durationAsString + "] in a Duration object");
// }
// }
//
//
// // -----------------------------------------------------------------------
//
// public long toNanos() { return unit.toNanos(duration); }
// public long toMicros() { return unit.toMicros(duration); }
// public long toMillis() { return unit.toMillis(duration); }
// public long toSeconds() { return unit.toSeconds(duration); }
// public long toMinutes() { return unit.toMinutes(duration); }
// public long toHours() { return unit.toHours(duration); }
// public long toDays() { return unit.toDays(duration); }
//
//
// // -----------------------------------------------------------------------
//
// public boolean hasNanos() {
// return true;
// }
// public boolean hasMicros() {
// return unit.toMicros(duration) > 0;
// }
// public boolean hasMillis() {
// return unit.toMillis(duration) > 0;
// }
// public boolean hasSeconds() {
// return unit.toSeconds(duration) > 0;
// }
// public boolean hasMinutes() {
// return unit.toMinutes(duration) > 0;
// }
// public boolean hasHours() {
// return unit.toHours(duration) > 0;
// }
// public boolean hasDays() {
// return unit.toDays(duration) > 0;
// }
//
//
// // -----------------------------------------------------------------------
//
// public static Duration nanos(long duration) {
// return new Duration(duration, TimeUnit.NANOSECONDS);
// }
// public static Duration micros(long duration) {
// return new Duration(duration, TimeUnit.MICROSECONDS);
// }
// public static Duration millis(long duration) {
// return new Duration(duration, TimeUnit.MILLISECONDS);
// }
// public static Duration seconds(long duration) {
// return new Duration(duration, TimeUnit.SECONDS);
// }
// public static Duration minutes(long duration) {
// return new Duration(duration, TimeUnit.MINUTES);
// }
// public static Duration hours(long duration) {
// return new Duration(duration, TimeUnit.HOURS);
// }
// public static Duration days(long duration) {
// return new Duration(duration, TimeUnit.DAYS);
// }
// }
| import static org.junit.Assert.*;
import java.beans.PropertyEditor;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.tzavellas.circuitbreaker.util.Duration; | package com.tzavellas.circuitbreaker.util;
public class DurationTest {
@Test
public void has_past_since_tests() {
// time dependent test (to System.nanoTime). | // Path: src/main/java/com/tzavellas/circuitbreaker/util/Duration.java
// public final class Duration {
//
// /** A {@code PropertyEditor} for {@code Duration} objects. */
// public static class Editor extends PropertyEditorSupport {
// /** {@inheritDoc} */
// public String getAsText() {
// return getValue().toString();
// }
// /** {@inheritDoc} */
// public void setAsText(String text) throws IllegalArgumentException {
// setValue(Duration.valueOf(text));
// }
// }
//
//
// // -----------------------------------------------------------------------
//
// private final long duration;
// private final TimeUnit unit;
//
// public Duration(long duration, TimeUnit unit) {
// this.duration = duration;
// this.unit = unit;
// }
//
// public boolean hasPastSince(long nanos) {
// long now = System.nanoTime();
// return now - nanos >= toNanos();
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj instanceof Duration) {
// Duration that = (Duration) obj;
// return this.toNanos() == that.toNanos();
// }
// return false;
// }
//
// @Override
// public int hashCode() {
// return 37 * Long.valueOf(toNanos()).hashCode() * TimeUnit.NANOSECONDS.hashCode();
// }
//
// @Override
// public String toString() {
// String unitString = null;
// switch (unit) {
// case NANOSECONDS: unitString = "ns"; break;
// case MICROSECONDS: unitString = "us"; break;
// case MILLISECONDS: unitString = "ms"; break;
// case SECONDS: unitString = "s"; break;
// case MINUTES: unitString = "m"; break;
// case HOURS: unitString = "h"; break;
// case DAYS: unitString = "d"; break;
// default:
// throw new AssertionError();
// }
// return duration + unitString;
// }
//
// public static Duration valueOf(String durationAsString) {
// try {
// Scanner s = new Scanner(durationAsString);
// s.findInLine("(\\d+)[\\s]*([μ]*\\w+)");
// MatchResult result = s.match();
// long duration = Long.valueOf(result.group(1));
// String us = result.group(2);
// TimeUnit unit = null;
// // order is important cause we have 2 matches for startsWith("m"): "m" an "ms"
// if (us.startsWith("d")) unit = TimeUnit.DAYS;
// if (us.startsWith("h")) unit = TimeUnit.HOURS;
// if (us.startsWith("m")) unit = TimeUnit.MINUTES;
// if (us.startsWith("s")) unit = TimeUnit.SECONDS;
// if (us.startsWith("ms")) unit = TimeUnit.MILLISECONDS;
// if (us.startsWith("us")) unit = TimeUnit.MICROSECONDS;
// if (us.startsWith("ns")) unit = TimeUnit.NANOSECONDS;
// if (unit == null) throw new NullPointerException();
//
// return new Duration(duration, unit);
// } catch (RuntimeException e) {
// throw new IllegalArgumentException("Could not parse [" + durationAsString + "] in a Duration object");
// }
// }
//
//
// // -----------------------------------------------------------------------
//
// public long toNanos() { return unit.toNanos(duration); }
// public long toMicros() { return unit.toMicros(duration); }
// public long toMillis() { return unit.toMillis(duration); }
// public long toSeconds() { return unit.toSeconds(duration); }
// public long toMinutes() { return unit.toMinutes(duration); }
// public long toHours() { return unit.toHours(duration); }
// public long toDays() { return unit.toDays(duration); }
//
//
// // -----------------------------------------------------------------------
//
// public boolean hasNanos() {
// return true;
// }
// public boolean hasMicros() {
// return unit.toMicros(duration) > 0;
// }
// public boolean hasMillis() {
// return unit.toMillis(duration) > 0;
// }
// public boolean hasSeconds() {
// return unit.toSeconds(duration) > 0;
// }
// public boolean hasMinutes() {
// return unit.toMinutes(duration) > 0;
// }
// public boolean hasHours() {
// return unit.toHours(duration) > 0;
// }
// public boolean hasDays() {
// return unit.toDays(duration) > 0;
// }
//
//
// // -----------------------------------------------------------------------
//
// public static Duration nanos(long duration) {
// return new Duration(duration, TimeUnit.NANOSECONDS);
// }
// public static Duration micros(long duration) {
// return new Duration(duration, TimeUnit.MICROSECONDS);
// }
// public static Duration millis(long duration) {
// return new Duration(duration, TimeUnit.MILLISECONDS);
// }
// public static Duration seconds(long duration) {
// return new Duration(duration, TimeUnit.SECONDS);
// }
// public static Duration minutes(long duration) {
// return new Duration(duration, TimeUnit.MINUTES);
// }
// public static Duration hours(long duration) {
// return new Duration(duration, TimeUnit.HOURS);
// }
// public static Duration days(long duration) {
// return new Duration(duration, TimeUnit.DAYS);
// }
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/util/DurationTest.java
import static org.junit.Assert.*;
import java.beans.PropertyEditor;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.tzavellas.circuitbreaker.util.Duration;
package com.tzavellas.circuitbreaker.util;
public class DurationTest {
@Test
public void has_past_since_tests() {
// time dependent test (to System.nanoTime). | assertTrue(Duration.nanos(1).hasPastSince(System.nanoTime())); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/aspectj/JmxTest.java | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java
// public abstract class AbstractJmxTest {
//
// protected ITimeService time;
//
// protected abstract void disableJmx();
//
// protected CircuitBreakerMBean mbean() throws JMException {
// return JmxUtils.getCircuitBreaker(time);
// }
//
// protected void readStatsAndOpenCircuitViaJmx() throws Exception {
// time.networkTime();
//
// CircuitBreakerMBean mbean = mbean();
// assertTrue(mbean.getCalls() >= 1);
// assertEquals(0, mbean.getCurrentFailures());
// assertEquals(0, mbean.getFailures());
// assertEquals(0, mbean.getTimesOpened());
// assertTrue(mbean.isClosed());
// assertFalse(mbean.isHalfOpen());
// assertFalse(mbean.isOpen());
//
// mbean.open();
// assertTrue(mbean.isOpen());
// time.networkTime();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/OpenCircuitException.java
// public class OpenCircuitException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final transient CircuitInfo circuit;
//
// /**
// * Create an OpenCircuitException.
// *
// * @param c the {@code CircuitInfo} that caused this exception.
// */
// public OpenCircuitException(CircuitInfo c) {
// circuit = c;
// }
//
// /**
// * Get the {@code CircuitInfo} that is open and caused this
// * exception to be thrown.
// *
// * @return the {@code CircuitInfo} that caused this exception.
// */
// public CircuitInfo getCircuit() {
// return circuit;
// }
//
// /**
// * Overridden to return null to avoid the cost of creating the stack
// * trace.
// *
// * <p>This can be done because this exception is used as a control
// * structure and not to report any error.</p>
// */
// @Override
// public synchronized Throwable fillInStackTrace() {
// return null;
// }
// }
//
// Path: src/test/java/com/tzavellas/test/aj/TimeService.java
// @IntegrationPoint
// public class TimeService implements ITimeService {
//
// public Date networkTime() {
// return EXPECTED;
// }
//
// public Date faultyNetworkTime() {
// throw new IllegalStateException();
// }
// }
| import org.junit.After;
import org.junit.Test;
import com.tzavellas.circuitbreaker.AbstractJmxTest;
import com.tzavellas.circuitbreaker.OpenCircuitException;
import com.tzavellas.test.aj.TimeService; | package com.tzavellas.circuitbreaker.aspectj;
public class JmxTest extends AbstractJmxTest {
@After
public void disableJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
IntegrationPointBreaker.aspectOf(time).setEnableJmx(false);
}
| // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java
// public abstract class AbstractJmxTest {
//
// protected ITimeService time;
//
// protected abstract void disableJmx();
//
// protected CircuitBreakerMBean mbean() throws JMException {
// return JmxUtils.getCircuitBreaker(time);
// }
//
// protected void readStatsAndOpenCircuitViaJmx() throws Exception {
// time.networkTime();
//
// CircuitBreakerMBean mbean = mbean();
// assertTrue(mbean.getCalls() >= 1);
// assertEquals(0, mbean.getCurrentFailures());
// assertEquals(0, mbean.getFailures());
// assertEquals(0, mbean.getTimesOpened());
// assertTrue(mbean.isClosed());
// assertFalse(mbean.isHalfOpen());
// assertFalse(mbean.isOpen());
//
// mbean.open();
// assertTrue(mbean.isOpen());
// time.networkTime();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/OpenCircuitException.java
// public class OpenCircuitException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final transient CircuitInfo circuit;
//
// /**
// * Create an OpenCircuitException.
// *
// * @param c the {@code CircuitInfo} that caused this exception.
// */
// public OpenCircuitException(CircuitInfo c) {
// circuit = c;
// }
//
// /**
// * Get the {@code CircuitInfo} that is open and caused this
// * exception to be thrown.
// *
// * @return the {@code CircuitInfo} that caused this exception.
// */
// public CircuitInfo getCircuit() {
// return circuit;
// }
//
// /**
// * Overridden to return null to avoid the cost of creating the stack
// * trace.
// *
// * <p>This can be done because this exception is used as a control
// * structure and not to report any error.</p>
// */
// @Override
// public synchronized Throwable fillInStackTrace() {
// return null;
// }
// }
//
// Path: src/test/java/com/tzavellas/test/aj/TimeService.java
// @IntegrationPoint
// public class TimeService implements ITimeService {
//
// public Date networkTime() {
// return EXPECTED;
// }
//
// public Date faultyNetworkTime() {
// throw new IllegalStateException();
// }
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/aspectj/JmxTest.java
import org.junit.After;
import org.junit.Test;
import com.tzavellas.circuitbreaker.AbstractJmxTest;
import com.tzavellas.circuitbreaker.OpenCircuitException;
import com.tzavellas.test.aj.TimeService;
package com.tzavellas.circuitbreaker.aspectj;
public class JmxTest extends AbstractJmxTest {
@After
public void disableJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
IntegrationPointBreaker.aspectOf(time).setEnableJmx(false);
}
| @Test(expected=OpenCircuitException.class) |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/aspectj/JmxTest.java | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java
// public abstract class AbstractJmxTest {
//
// protected ITimeService time;
//
// protected abstract void disableJmx();
//
// protected CircuitBreakerMBean mbean() throws JMException {
// return JmxUtils.getCircuitBreaker(time);
// }
//
// protected void readStatsAndOpenCircuitViaJmx() throws Exception {
// time.networkTime();
//
// CircuitBreakerMBean mbean = mbean();
// assertTrue(mbean.getCalls() >= 1);
// assertEquals(0, mbean.getCurrentFailures());
// assertEquals(0, mbean.getFailures());
// assertEquals(0, mbean.getTimesOpened());
// assertTrue(mbean.isClosed());
// assertFalse(mbean.isHalfOpen());
// assertFalse(mbean.isOpen());
//
// mbean.open();
// assertTrue(mbean.isOpen());
// time.networkTime();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/OpenCircuitException.java
// public class OpenCircuitException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final transient CircuitInfo circuit;
//
// /**
// * Create an OpenCircuitException.
// *
// * @param c the {@code CircuitInfo} that caused this exception.
// */
// public OpenCircuitException(CircuitInfo c) {
// circuit = c;
// }
//
// /**
// * Get the {@code CircuitInfo} that is open and caused this
// * exception to be thrown.
// *
// * @return the {@code CircuitInfo} that caused this exception.
// */
// public CircuitInfo getCircuit() {
// return circuit;
// }
//
// /**
// * Overridden to return null to avoid the cost of creating the stack
// * trace.
// *
// * <p>This can be done because this exception is used as a control
// * structure and not to report any error.</p>
// */
// @Override
// public synchronized Throwable fillInStackTrace() {
// return null;
// }
// }
//
// Path: src/test/java/com/tzavellas/test/aj/TimeService.java
// @IntegrationPoint
// public class TimeService implements ITimeService {
//
// public Date networkTime() {
// return EXPECTED;
// }
//
// public Date faultyNetworkTime() {
// throw new IllegalStateException();
// }
// }
| import org.junit.After;
import org.junit.Test;
import com.tzavellas.circuitbreaker.AbstractJmxTest;
import com.tzavellas.circuitbreaker.OpenCircuitException;
import com.tzavellas.test.aj.TimeService; | package com.tzavellas.circuitbreaker.aspectj;
public class JmxTest extends AbstractJmxTest {
@After
public void disableJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
IntegrationPointBreaker.aspectOf(time).setEnableJmx(false);
}
@Test(expected=OpenCircuitException.class)
public void enable_jmx_via_configurator() throws Exception {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(true); | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java
// public abstract class AbstractJmxTest {
//
// protected ITimeService time;
//
// protected abstract void disableJmx();
//
// protected CircuitBreakerMBean mbean() throws JMException {
// return JmxUtils.getCircuitBreaker(time);
// }
//
// protected void readStatsAndOpenCircuitViaJmx() throws Exception {
// time.networkTime();
//
// CircuitBreakerMBean mbean = mbean();
// assertTrue(mbean.getCalls() >= 1);
// assertEquals(0, mbean.getCurrentFailures());
// assertEquals(0, mbean.getFailures());
// assertEquals(0, mbean.getTimesOpened());
// assertTrue(mbean.isClosed());
// assertFalse(mbean.isHalfOpen());
// assertFalse(mbean.isOpen());
//
// mbean.open();
// assertTrue(mbean.isOpen());
// time.networkTime();
// }
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/OpenCircuitException.java
// public class OpenCircuitException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final transient CircuitInfo circuit;
//
// /**
// * Create an OpenCircuitException.
// *
// * @param c the {@code CircuitInfo} that caused this exception.
// */
// public OpenCircuitException(CircuitInfo c) {
// circuit = c;
// }
//
// /**
// * Get the {@code CircuitInfo} that is open and caused this
// * exception to be thrown.
// *
// * @return the {@code CircuitInfo} that caused this exception.
// */
// public CircuitInfo getCircuit() {
// return circuit;
// }
//
// /**
// * Overridden to return null to avoid the cost of creating the stack
// * trace.
// *
// * <p>This can be done because this exception is used as a control
// * structure and not to report any error.</p>
// */
// @Override
// public synchronized Throwable fillInStackTrace() {
// return null;
// }
// }
//
// Path: src/test/java/com/tzavellas/test/aj/TimeService.java
// @IntegrationPoint
// public class TimeService implements ITimeService {
//
// public Date networkTime() {
// return EXPECTED;
// }
//
// public Date faultyNetworkTime() {
// throw new IllegalStateException();
// }
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/aspectj/JmxTest.java
import org.junit.After;
import org.junit.Test;
import com.tzavellas.circuitbreaker.AbstractJmxTest;
import com.tzavellas.circuitbreaker.OpenCircuitException;
import com.tzavellas.test.aj.TimeService;
package com.tzavellas.circuitbreaker.aspectj;
public class JmxTest extends AbstractJmxTest {
@After
public void disableJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
IntegrationPointBreaker.aspectOf(time).setEnableJmx(false);
}
@Test(expected=OpenCircuitException.class)
public void enable_jmx_via_configurator() throws Exception {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(true); | time = new TimeService(); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
| import static org.junit.Assert.*;
import javax.management.JMException;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService; | package com.tzavellas.circuitbreaker;
public abstract class AbstractJmxTest {
protected ITimeService time;
protected abstract void disableJmx();
| // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java
import static org.junit.Assert.*;
import javax.management.JMException;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService;
package com.tzavellas.circuitbreaker;
public abstract class AbstractJmxTest {
protected ITimeService time;
protected abstract void disableJmx();
| protected CircuitBreakerMBean mbean() throws JMException { |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
| import static org.junit.Assert.*;
import javax.management.JMException;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService; | package com.tzavellas.circuitbreaker;
public abstract class AbstractJmxTest {
protected ITimeService time;
protected abstract void disableJmx();
protected CircuitBreakerMBean mbean() throws JMException { | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/AbstractJmxTest.java
import static org.junit.Assert.*;
import javax.management.JMException;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService;
package com.tzavellas.circuitbreaker;
public abstract class AbstractJmxTest {
protected ITimeService time;
protected abstract void disableJmx();
protected CircuitBreakerMBean mbean() throws JMException { | return JmxUtils.getCircuitBreaker(time); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/aspectj/ConfigFromSpringTest.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
| import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService; | package com.tzavellas.circuitbreaker.aspectj;
public class ConfigFromSpringTest {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/aspectj-impl-context.xml"); | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/aspectj/ConfigFromSpringTest.java
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService;
package com.tzavellas.circuitbreaker.aspectj;
public class ConfigFromSpringTest {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/aspectj-impl-context.xml"); | final ITimeService time = (ITimeService) context.getBean("timeService"); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/aspectj/ConfigFromSpringTest.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
| import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService; | package com.tzavellas.circuitbreaker.aspectj;
public class ConfigFromSpringTest {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/aspectj-impl-context.xml");
final ITimeService time = (ITimeService) context.getBean("timeService");
@After
public void unregisterFromJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
breaker().setEnableJmx(false);
}
@Test
public void open_and_close_via_jmx() throws Exception {
generateFaults(1);
assertTrue(breaker().getCircuitInfo().isOpen());
| // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/aspectj/ConfigFromSpringTest.java
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService;
package com.tzavellas.circuitbreaker.aspectj;
public class ConfigFromSpringTest {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/aspectj-impl-context.xml");
final ITimeService time = (ITimeService) context.getBean("timeService");
@After
public void unregisterFromJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
breaker().setEnableJmx(false);
}
@Test
public void open_and_close_via_jmx() throws Exception {
generateFaults(1);
assertTrue(breaker().getCircuitInfo().isOpen());
| CircuitBreakerMBean mbean = JmxUtils.getCircuitBreaker(time); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/aspectj/ConfigFromSpringTest.java | // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
| import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService; | package com.tzavellas.circuitbreaker.aspectj;
public class ConfigFromSpringTest {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/aspectj-impl-context.xml");
final ITimeService time = (ITimeService) context.getBean("timeService");
@After
public void unregisterFromJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
breaker().setEnableJmx(false);
}
@Test
public void open_and_close_via_jmx() throws Exception {
generateFaults(1);
assertTrue(breaker().getCircuitInfo().isOpen());
| // Path: src/main/java/com/tzavellas/circuitbreaker/jmx/CircuitBreakerMBean.java
// public interface CircuitBreakerMBean {
//
// /**
// * Test whether the circuit is open.
// */
// boolean isOpen();
//
// /**
// * Open the circuit, causing any subsequent calls made through the
// * circuit to stop throwing an OpenCircuitException.
// */
// void open();
//
// /**
// * Test whether the circuit is closed.
// */
// boolean isClosed();
//
// /**
// * Close the circuit, allowing any method call to propagate to
// * their recipients.
// */
// void close();
//
// /**
// * Test whether the circuit is open.
// */
// boolean isHalfOpen();
//
// /**
// * Get the Date the circuit was opened.
// *
// * @return if the circuit is open return the open timestamp else null
// */
// Date getOpenTimestamp();
//
// /**
// * The number of calls being made through the circuit.
// */
// int getCalls();
//
// /**
// * The number of total failures.
// */
// int getFailures();
//
// /**
// * The number of failures since the circuit was closed.
// */
// int getCurrentFailures();
//
// /**
// * The number of times the circuit has been opened.
// */
// int getTimesOpened();
//
// /**
// * The number of failures after the circuit opens.
// */
// int getMaxFailures();
//
// /**
// * Set the number of failures after the circuit opens.
// */
// void setMaxFailures(int n);
//
// /**
// * The timeout after which the circuit closes.
// */
// String getTimeout();
//
// /**
// * Set the timeout after which the circuit closes.
// *
// * @param timeout a String formated Duration
// *
// * @see Duration
// */
// void setTimeout(String timeout);
//
// /**
// * Get the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// */
// String getCurrentFailuresDuration();
//
// /**
// * Specify the duration after which the number of failures tracked by
// * the circuit breaker gets reset.
// *
// * @param duration a string representing a {@code Duration} object.
// *
// * @see Duration
// */
// void setCurrentFailuresDuration(String duration);
//
// /**
// * Get the duration after which a method execution is considered a failure.
// */
// String getMaxMethodDuration();
//
// /**
// * Set the duration after which a method execution is considered a failure.
// *
// * @param d a String formated Duration or <code>null</code> if you want to disable
// * the tracking of execution time.
// *
// * @see Duration
// */
// void setMaxMethodDuration(String duration);
// }
//
// Path: src/main/java/com/tzavellas/circuitbreaker/jmx/JmxUtils.java
// public abstract class JmxUtils {
//
// private JmxUtils() { }
//
// private static CircuitBreakerMBean getCircuitBreaker(ObjectName name) throws JMException {
// return JMX.newMBeanProxy(
// ManagementFactory.getPlatformMBeanServer(),
// name,
// CircuitBreakerMBean.class);
// }
//
// public static CircuitBreakerMBean getCircuitBreaker(Object target) throws JMException {
// return getCircuitBreaker(new ObjectName(getObjectName(target)));
// }
//
// public static Set<CircuitBreakerMBean> circuitBreakersForType(Class<?> targetClass) throws JMException {
// MBeanServer server = ManagementFactory.getPlatformMBeanServer();
// String query = String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=*", targetClass.getSimpleName());
// Set<ObjectName> names = server.queryNames(new ObjectName(query), null);
// Set<CircuitBreakerMBean> mbeans = new HashSet<CircuitBreakerMBean>();
// for (ObjectName name: names)
// mbeans.add(getCircuitBreaker(name));
// return mbeans;
// }
//
// public static String getObjectName(Object target) {
// return String.format("com.tzavellas.circuitbreaker:type=CircuitBreaker,target=%s,code=%d",
// target.getClass().getSimpleName(),
// target.hashCode());
// }
// }
//
// Path: src/test/java/com/tzavellas/test/ITimeService.java
// public interface ITimeService {
//
// Date EXPECTED = new Date();
//
// Date networkTime();
//
// Date faultyNetworkTime();
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/aspectj/ConfigFromSpringTest.java
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tzavellas.circuitbreaker.jmx.CircuitBreakerMBean;
import com.tzavellas.circuitbreaker.jmx.JmxUtils;
import com.tzavellas.test.ITimeService;
package com.tzavellas.circuitbreaker.aspectj;
public class ConfigFromSpringTest {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/aspectj-impl-context.xml");
final ITimeService time = (ITimeService) context.getBean("timeService");
@After
public void unregisterFromJmx() {
CircuitBreakerConfigurator.aspectOf().setEnableJmx(false);
breaker().setEnableJmx(false);
}
@Test
public void open_and_close_via_jmx() throws Exception {
generateFaults(1);
assertTrue(breaker().getCircuitInfo().isOpen());
| CircuitBreakerMBean mbean = JmxUtils.getCircuitBreaker(time); |
sptz45/circuit-breaker | src/test/java/com/tzavellas/circuitbreaker/spring/CircuitBreakerTest.java | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractCircuitBreakerTest.java
// public abstract class AbstractCircuitBreakerTest {
//
// protected IStockService stocks;
// protected CircuitBreakerAspectSupport stocksBreaker;
//
// @Before
// public void resetCircuit() {
// // this is needed because in Spring the service and the aspect are singletons.
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.close();
// circuit.resetToDefaultConfig();
// circuit.resetStatistics();
// }
//
// @Test
// public void normal_operation_while_closed() {
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test(expected=OpenCircuitException.class)
// public void after_a_number_of_faults_the_circuit_opens() {
// generateFaultsToOpen();
// stocks.getQuote("JAVA");
// }
//
// @Test
// public void the_circuit_can_be_opened_after_being_closed() {
// generateFaultsToOpen();
// try {
// stocks.getQuote("JAVA");
// } catch (OpenCircuitException e) {
// CircuitInfo c = e.getCircuit();
// assertTrue(c.isOpen());
// c.close();
// assertFalse(c.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// return;
// }
// fail("Should have raised an OpenCircuitException");
// }
//
// @Test
// public void the_circuit_is_half_open_after_the_timeout() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// assertEquals(0, circuit.getCurrentFailures());
// }
//
// @Test
// public void the_circuit_moves_from_half_open_to_open_on_first_failure() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// try { stocks.faultyGetQuote("JAVA"); } catch (RuntimeException expected) { }
// assertTrue(circuit.isOpen());
// }
//
// @Test
// public void the_failure_count_gets_reset_after_an_amount_of_time() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.millis(1));
//
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES - 1);
// assertFalse(circuit.isOpen());
// Thread.sleep(5);
//
// generateFaults(1);
// assertFalse(circuit.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test
// public void almost_instant_failure_count_reset() {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.nanos(1));
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(circuit.isOpen());
// }
//
// @Test
// public void ignored_exceptions_do_not_open_a_circuit() {
// stocksBreaker.ignoreException(ArithmeticException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(ArithmeticException.class);
// }
//
// @Test
// public void ignored_exceptions_capture_subclasses() {
// stocksBreaker.ignoreException(RuntimeException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(RuntimeException.class);
// }
//
// @Test
// public void slow_metnod_executions_count_as_failures() {
// stocksBreaker.setMaxMethodDuration(Duration.nanos(1));
// for (int i = 0; i < CircuitInfo.DEFAULT_MAX_FAILURES; i++)
// stocks.getQuote("JAVA");
// assertTrue(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.setMaxMethodDuration(null);
// }
//
//
// //------------------------------------------------------------------------
//
// protected void generateFaultsToOpen() {
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES);
// }
//
// protected void generateFaults(int numOfFaults) {
// for (int i = 0; i < numOfFaults; i++) {
// try { stocks.faultyGetQuote("JAVA"); } catch (ArithmeticException expected) { }
// }
// }
// }
//
// Path: src/test/java/com/tzavellas/test/IStockService.java
// public interface IStockService {
//
// int getQuote(String ticker);
//
// int faultyGetQuote(String ticker);
// }
| import com.tzavellas.circuitbreaker.AbstractCircuitBreakerTest;
import com.tzavellas.test.IStockService; | package com.tzavellas.circuitbreaker.spring;
public class CircuitBreakerTest extends AbstractCircuitBreakerTest {
public CircuitBreakerTest() { | // Path: src/test/java/com/tzavellas/circuitbreaker/AbstractCircuitBreakerTest.java
// public abstract class AbstractCircuitBreakerTest {
//
// protected IStockService stocks;
// protected CircuitBreakerAspectSupport stocksBreaker;
//
// @Before
// public void resetCircuit() {
// // this is needed because in Spring the service and the aspect are singletons.
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.close();
// circuit.resetToDefaultConfig();
// circuit.resetStatistics();
// }
//
// @Test
// public void normal_operation_while_closed() {
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test(expected=OpenCircuitException.class)
// public void after_a_number_of_faults_the_circuit_opens() {
// generateFaultsToOpen();
// stocks.getQuote("JAVA");
// }
//
// @Test
// public void the_circuit_can_be_opened_after_being_closed() {
// generateFaultsToOpen();
// try {
// stocks.getQuote("JAVA");
// } catch (OpenCircuitException e) {
// CircuitInfo c = e.getCircuit();
// assertTrue(c.isOpen());
// c.close();
// assertFalse(c.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// return;
// }
// fail("Should have raised an OpenCircuitException");
// }
//
// @Test
// public void the_circuit_is_half_open_after_the_timeout() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// assertEquals(0, circuit.getCurrentFailures());
// }
//
// @Test
// public void the_circuit_moves_from_half_open_to_open_on_first_failure() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setTimeout(Duration.millis(1));
// generateFaultsToOpen();
// Thread.sleep(2);
// assertTrue(circuit.isHalfOpen());
// try { stocks.faultyGetQuote("JAVA"); } catch (RuntimeException expected) { }
// assertTrue(circuit.isOpen());
// }
//
// @Test
// public void the_failure_count_gets_reset_after_an_amount_of_time() throws Exception {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.millis(1));
//
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES - 1);
// assertFalse(circuit.isOpen());
// Thread.sleep(5);
//
// generateFaults(1);
// assertFalse(circuit.isOpen());
// assertEquals(5, stocks.getQuote("JAVA"));
// }
//
// @Test
// public void almost_instant_failure_count_reset() {
// CircuitInfo circuit = stocksBreaker.getCircuitInfo();
// circuit.setCurrentFailuresDuration(Duration.nanos(1));
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(circuit.isOpen());
// }
//
// @Test
// public void ignored_exceptions_do_not_open_a_circuit() {
// stocksBreaker.ignoreException(ArithmeticException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(ArithmeticException.class);
// }
//
// @Test
// public void ignored_exceptions_capture_subclasses() {
// stocksBreaker.ignoreException(RuntimeException.class);
// generateFaultsToOpen();
// assertEquals(5, stocks.getQuote("JAVA"));
// assertFalse(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.removeIgnoredExcpetion(RuntimeException.class);
// }
//
// @Test
// public void slow_metnod_executions_count_as_failures() {
// stocksBreaker.setMaxMethodDuration(Duration.nanos(1));
// for (int i = 0; i < CircuitInfo.DEFAULT_MAX_FAILURES; i++)
// stocks.getQuote("JAVA");
// assertTrue(stocksBreaker.getCircuitInfo().isOpen());
// stocksBreaker.setMaxMethodDuration(null);
// }
//
//
// //------------------------------------------------------------------------
//
// protected void generateFaultsToOpen() {
// generateFaults(CircuitInfo.DEFAULT_MAX_FAILURES);
// }
//
// protected void generateFaults(int numOfFaults) {
// for (int i = 0; i < numOfFaults; i++) {
// try { stocks.faultyGetQuote("JAVA"); } catch (ArithmeticException expected) { }
// }
// }
// }
//
// Path: src/test/java/com/tzavellas/test/IStockService.java
// public interface IStockService {
//
// int getQuote(String ticker);
//
// int faultyGetQuote(String ticker);
// }
// Path: src/test/java/com/tzavellas/circuitbreaker/spring/CircuitBreakerTest.java
import com.tzavellas.circuitbreaker.AbstractCircuitBreakerTest;
import com.tzavellas.test.IStockService;
package com.tzavellas.circuitbreaker.spring;
public class CircuitBreakerTest extends AbstractCircuitBreakerTest {
public CircuitBreakerTest() { | stocks = (IStockService) SpringLoader.CONTEXT.getBean("stockService"); |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
| import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr; | /*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.winrun4j;
public class Registry
{
static {
PInvoke.bind(Registry.class, "advapi32.dll");
}
// Value Types
public static final int REG_NONE = 0;
public static final int REG_SZ = 1;
public static final int REG_EXPAND_SZ = 2;
public static final int REG_BINARY = 3;
public static final int REG_DWORD = 4;
public static final int REG_DWORD_LITTLE_ENDIAN = 4;
public static final int REG_DWORD_BIG_ENDIAN = 5;
public static final int REG_LINK = 6;
public static final int REG_MULTI_SZ = 7;
public static final int REG_RESOURCE_LIST = 8;
public static final int REG_FULL_RESOURCE_DESCRIPTOR = 9;
public static final int REG_RESOURCE_REQUIREMENTS_LIST = 10;
public static final int REG_QWORD = 11;
public static final int REG_QWORD_LITTLE_ENDIAN = 11;
@DllImport(entryPoint = "RegCloseKey")
public static native int closeKey(long hKey);
@DllImport(entryPoint = "RegCreateKeyW") | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr;
/*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.winrun4j;
public class Registry
{
static {
PInvoke.bind(Registry.class, "advapi32.dll");
}
// Value Types
public static final int REG_NONE = 0;
public static final int REG_SZ = 1;
public static final int REG_EXPAND_SZ = 2;
public static final int REG_BINARY = 3;
public static final int REG_DWORD = 4;
public static final int REG_DWORD_LITTLE_ENDIAN = 4;
public static final int REG_DWORD_BIG_ENDIAN = 5;
public static final int REG_LINK = 6;
public static final int REG_MULTI_SZ = 7;
public static final int REG_RESOURCE_LIST = 8;
public static final int REG_FULL_RESOURCE_DESCRIPTOR = 9;
public static final int REG_RESOURCE_REQUIREMENTS_LIST = 10;
public static final int REG_QWORD = 11;
public static final int REG_QWORD_LITTLE_ENDIAN = 11;
@DllImport(entryPoint = "RegCloseKey")
public static native int closeKey(long hKey);
@DllImport(entryPoint = "RegCreateKeyW") | public static native int createKey(long hKey, String lpSubKey, @Out UIntPtr phkResult); |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
| import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr; | public static native int createKey(long hKey, String lpSubKey, @Out UIntPtr phkResult);
@DllImport(entryPoint = "RegDeleteKeyW")
public static native long deleteKey(long hKey, String subKey);
@DllImport(entryPoint = "RegDeleteValueW")
public static native long deleteValue(long hKey, String valueName);
@DllImport(entryPoint = "RegOpenKeyExW")
public static native int openKeyEx(long hKey, String subKey, int options, long samDesired, UIntPtr phkResult);
@DllImport(entryPoint = "RegEnumKeyExW")
public static native int enumKeyEx(
long hkey,
int index,
StringBuilder lpName,
UIntPtr lpcbName,
long reserved,
long lpClass,
long lpcbClass,
FILETIME lpftLastWriteTime);
@DllImport(entryPoint = "RegEnumValue")
public static native int enumValue(
long hKey,
int index,
StringBuilder lpValueName,
UIntPtr lpcValueName,
long lpReserved,
UIntPtr lpType, | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr;
public static native int createKey(long hKey, String lpSubKey, @Out UIntPtr phkResult);
@DllImport(entryPoint = "RegDeleteKeyW")
public static native long deleteKey(long hKey, String subKey);
@DllImport(entryPoint = "RegDeleteValueW")
public static native long deleteValue(long hKey, String valueName);
@DllImport(entryPoint = "RegOpenKeyExW")
public static native int openKeyEx(long hKey, String subKey, int options, long samDesired, UIntPtr phkResult);
@DllImport(entryPoint = "RegEnumKeyExW")
public static native int enumKeyEx(
long hkey,
int index,
StringBuilder lpName,
UIntPtr lpcbName,
long reserved,
long lpClass,
long lpcbClass,
FILETIME lpftLastWriteTime);
@DllImport(entryPoint = "RegEnumValue")
public static native int enumValue(
long hKey,
int index,
StringBuilder lpValueName,
UIntPtr lpcValueName,
long lpReserved,
UIntPtr lpType, | ByteArrayBuilder lpData, |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
| import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr; |
@DllImport(entryPoint = "RegDeleteKeyW")
public static native long deleteKey(long hKey, String subKey);
@DllImport(entryPoint = "RegDeleteValueW")
public static native long deleteValue(long hKey, String valueName);
@DllImport(entryPoint = "RegOpenKeyExW")
public static native int openKeyEx(long hKey, String subKey, int options, long samDesired, UIntPtr phkResult);
@DllImport(entryPoint = "RegEnumKeyExW")
public static native int enumKeyEx(
long hkey,
int index,
StringBuilder lpName,
UIntPtr lpcbName,
long reserved,
long lpClass,
long lpcbClass,
FILETIME lpftLastWriteTime);
@DllImport(entryPoint = "RegEnumValue")
public static native int enumValue(
long hKey,
int index,
StringBuilder lpValueName,
UIntPtr lpcValueName,
long lpReserved,
UIntPtr lpType,
ByteArrayBuilder lpData, | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr;
@DllImport(entryPoint = "RegDeleteKeyW")
public static native long deleteKey(long hKey, String subKey);
@DllImport(entryPoint = "RegDeleteValueW")
public static native long deleteValue(long hKey, String valueName);
@DllImport(entryPoint = "RegOpenKeyExW")
public static native int openKeyEx(long hKey, String subKey, int options, long samDesired, UIntPtr phkResult);
@DllImport(entryPoint = "RegEnumKeyExW")
public static native int enumKeyEx(
long hkey,
int index,
StringBuilder lpName,
UIntPtr lpcbName,
long reserved,
long lpClass,
long lpcbClass,
FILETIME lpftLastWriteTime);
@DllImport(entryPoint = "RegEnumValue")
public static native int enumValue(
long hKey,
int index,
StringBuilder lpValueName,
UIntPtr lpcValueName,
long lpReserved,
UIntPtr lpType,
ByteArrayBuilder lpData, | IntPtr lpcbData); |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
| import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr; | QUERY_INFO info = new QUERY_INFO();
info.keyClass = lpClass.toString();
info.subKeyCount = lpcSubKeys.intValue();
info.maxSubkeyLen = lpcMaxSubKeyLen.intValue();
info.maxClassLen = lpcMaxClassLen.intValue();
info.valueCount = lpcValues.intValue();
info.maxValueNameLen = lpcMaxValueNameLen.intValue();
info.maxValueLen = lpcMaxValueLen.intValue();
info.cbSecurityDescriptor = lpcbSecurityDescriptor.intValue();
info.lastWriteTime = lastWriteTime;
return info;
}
@DllImport(entryPoint = "RegSetValueEx")
public static native long setValueEx(long hKey, String valueName,
int reserved, int type, byte[] data, int len);
public static class QUERY_INFO
{
public String keyClass;
public int subKeyCount;
public int maxSubkeyLen;
public int maxClassLen;
public int valueCount;
public int maxValueNameLen;
public int maxValueLen;
public int cbSecurityDescriptor;
public FILETIME lastWriteTime;
}
| // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class ByteArrayBuilder
// {
// private byte[] array;
//
// public void set(byte[] array) {
// this.array = array;
// }
//
// public byte[] toArray() {
// return array;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class IntPtr
// {
// public long value;
//
// public IntPtr() {
// }
//
// public IntPtr(long value) {
// this.value = value;
// }
//
// public int intValue() {
// return (int) value;
// }
//
// public String toString() {
// return Long.toString(value);
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public interface Struct
// {
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
import org.boris.winrun4j.PInvoke.ByteArrayBuilder;
import org.boris.winrun4j.PInvoke.DllImport;
import org.boris.winrun4j.PInvoke.IntPtr;
import org.boris.winrun4j.PInvoke.Out;
import org.boris.winrun4j.PInvoke.Struct;
import org.boris.winrun4j.PInvoke.UIntPtr;
QUERY_INFO info = new QUERY_INFO();
info.keyClass = lpClass.toString();
info.subKeyCount = lpcSubKeys.intValue();
info.maxSubkeyLen = lpcMaxSubKeyLen.intValue();
info.maxClassLen = lpcMaxClassLen.intValue();
info.valueCount = lpcValues.intValue();
info.maxValueNameLen = lpcMaxValueNameLen.intValue();
info.maxValueLen = lpcMaxValueLen.intValue();
info.cbSecurityDescriptor = lpcbSecurityDescriptor.intValue();
info.lastWriteTime = lastWriteTime;
return info;
}
@DllImport(entryPoint = "RegSetValueEx")
public static native long setValueEx(long hKey, String valueName,
int reserved, int type, byte[] data, int len);
public static class QUERY_INFO
{
public String keyClass;
public int subKeyCount;
public int maxSubkeyLen;
public int maxClassLen;
public int valueCount;
public int maxValueNameLen;
public int maxValueLen;
public int cbSecurityDescriptor;
public FILETIME lastWriteTime;
}
| public static class FILETIME implements Struct |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/RegistryKey.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
// public static class QUERY_INFO
// {
// public String keyClass;
// public int subKeyCount;
// public int maxSubkeyLen;
// public int maxClassLen;
// public int valueCount;
// public int maxValueNameLen;
// public int maxValueLen;
// public int cbSecurityDescriptor;
// public FILETIME lastWriteTime;
// }
| import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;
import org.boris.winrun4j.PInvoke.UIntPtr;
import org.boris.winrun4j.Registry.QUERY_INFO; | if (k.exists())
return defaultValue ? k.getString(null) : k.getString(p[p.length - 1]);
return null;
}
/**
* Opens up the key for this path. Windows doesn't provide a way to open up
* a path.
*/
private long openKeyHandle(long handle, String[] path, boolean readOnly) {
long h = handle;
if (path == null)
return h;
for (int i = 0; i < path.length; i++) {
long nh = openKeyHandle(h, path[i], readOnly);
if (h != handle)
Registry.closeKey(h);
h = nh;
}
return h;
}
/**
* Gets the subkeys for this key.
*
* @return String[].
*/
public String[] getSubKeyNames() {
long h = openKeyHandle(handle, path, true); | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
// public static class QUERY_INFO
// {
// public String keyClass;
// public int subKeyCount;
// public int maxSubkeyLen;
// public int maxClassLen;
// public int valueCount;
// public int maxValueNameLen;
// public int maxValueLen;
// public int cbSecurityDescriptor;
// public FILETIME lastWriteTime;
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/RegistryKey.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;
import org.boris.winrun4j.PInvoke.UIntPtr;
import org.boris.winrun4j.Registry.QUERY_INFO;
if (k.exists())
return defaultValue ? k.getString(null) : k.getString(p[p.length - 1]);
return null;
}
/**
* Opens up the key for this path. Windows doesn't provide a way to open up
* a path.
*/
private long openKeyHandle(long handle, String[] path, boolean readOnly) {
long h = handle;
if (path == null)
return h;
for (int i = 0; i < path.length; i++) {
long nh = openKeyHandle(h, path[i], readOnly);
if (h != handle)
Registry.closeKey(h);
h = nh;
}
return h;
}
/**
* Gets the subkeys for this key.
*
* @return String[].
*/
public String[] getSubKeyNames() {
long h = openKeyHandle(handle, path, true); | QUERY_INFO qi = Registry.queryInfoKey(h); |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/RegistryKey.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
// public static class QUERY_INFO
// {
// public String keyClass;
// public int subKeyCount;
// public int maxSubkeyLen;
// public int maxClassLen;
// public int valueCount;
// public int maxValueNameLen;
// public int maxValueLen;
// public int cbSecurityDescriptor;
// public FILETIME lastWriteTime;
// }
| import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;
import org.boris.winrun4j.PInvoke.UIntPtr;
import org.boris.winrun4j.Registry.QUERY_INFO; | /**
* Opens up the key for this path. Windows doesn't provide a way to open up
* a path.
*/
private long openKeyHandle(long handle, String[] path, boolean readOnly) {
long h = handle;
if (path == null)
return h;
for (int i = 0; i < path.length; i++) {
long nh = openKeyHandle(h, path[i], readOnly);
if (h != handle)
Registry.closeKey(h);
h = nh;
}
return h;
}
/**
* Gets the subkeys for this key.
*
* @return String[].
*/
public String[] getSubKeyNames() {
long h = openKeyHandle(handle, path, true);
QUERY_INFO qi = Registry.queryInfoKey(h);
if (qi == null)
return null;
String[] keys = new String[qi.subKeyCount];
for (int i = 0; i < keys.length; i++) {
StringBuilder name = new StringBuilder(); | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/PInvoke.java
// public static class UIntPtr extends IntPtr
// {
// public UIntPtr() {
// }
//
// public UIntPtr(long value) {
// this.value = value;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/Registry.java
// public static class QUERY_INFO
// {
// public String keyClass;
// public int subKeyCount;
// public int maxSubkeyLen;
// public int maxClassLen;
// public int valueCount;
// public int maxValueNameLen;
// public int maxValueLen;
// public int cbSecurityDescriptor;
// public FILETIME lastWriteTime;
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/RegistryKey.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;
import org.boris.winrun4j.PInvoke.UIntPtr;
import org.boris.winrun4j.Registry.QUERY_INFO;
/**
* Opens up the key for this path. Windows doesn't provide a way to open up
* a path.
*/
private long openKeyHandle(long handle, String[] path, boolean readOnly) {
long h = handle;
if (path == null)
return h;
for (int i = 0; i < path.length; i++) {
long nh = openKeyHandle(h, path[i], readOnly);
if (h != handle)
Registry.closeKey(h);
h = nh;
}
return h;
}
/**
* Gets the subkeys for this key.
*
* @return String[].
*/
public String[] getSubKeyNames() {
long h = openKeyHandle(handle, path, true);
QUERY_INFO qi = Registry.queryInfoKey(h);
if (qi == null)
return null;
String[] keys = new String[qi.subKeyCount];
for (int i = 0; i < keys.length; i++) {
StringBuilder name = new StringBuilder(); | UIntPtr cbName = new UIntPtr(qi.maxSubkeyLen + 1); |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/res/EmbeddedJarURLConnection.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/ByteBufferInputStream.java
// public class ByteBufferInputStream extends InputStream
// {
// private ByteBuffer bb;
//
// public ByteBufferInputStream(ByteBuffer bb) {
// this.bb = bb;
// }
//
// public int read() throws IOException {
// try {
// return bb.get() & Integer.MAX_VALUE;
// } catch (BufferUnderflowException e) {
// return -1;
// }
// }
//
// public int read(byte[] b) throws IOException {
// int len = b.length;
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, 0, len);
// return len;
// }
//
// public int read(byte[] b, int off, int len) throws IOException {
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, off, len);
// return len;
// }
//
// public long skip(long n) throws IOException {
// if (n > bb.remaining()) {
// n = bb.remaining();
// }
// bb.position((int) (bb.position() + n));
// return n;
// }
//
// public int available() throws IOException {
// return bb.remaining();
// }
//
// public boolean markSupported() {
// return false;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/EmbeddedClassLoader.java
// public class EmbeddedClassLoader extends URLClassLoader
// {
// private String[] jars;
// private ByteBuffer[] buffers;
//
// public EmbeddedClassLoader() {
// super(makeUrls(), ClassLoader.getSystemClassLoader());
// jars = listJars(null);
// buffers = new ByteBuffer[jars.length];
// for (int i = 0; i < buffers.length; i++) {
// buffers[i] = getJar(null, jars[i]);
// }
// }
//
// private static URL[] makeUrls() {
// String p = System.getProperty("java.class.path");
// if (p == null)
// return new URL[0];
// StringTokenizer st = new StringTokenizer(p, ";");
// ArrayList urls = new ArrayList();
// while (st.hasMoreTokens()) {
// try {
// urls.add(new URL(st.nextToken()));
// } catch (MalformedURLException e) {
// }
// }
// return (URL[]) urls.toArray(new URL[0]);
// }
//
// public URL findResource(String name) {
// try {
// return new URL("res:///" + name);
// } catch (MalformedURLException e) {
// return null;
// }
// }
//
// public InputStream getResourceAsStream(String name) {
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// if (name.equals(ze.getName())) {
// return zis;
// }
// }
// } catch (IOException e) {
// return null;
// }
// }
// return null;
// }
//
// protected Class findClass(String name) throws ClassNotFoundException {
// String cname = name.replace('.', '/').concat(".class");
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// String s = ze.getName();
// if (cname.equals(s)) {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// byte[] buf = new byte[4096];
// int len = 0;
// while ((len = zis.read(buf)) > 0) {
// bos.write(buf, 0, len);
// }
// byte[] cb = bos.toByteArray();
// return defineClass(name, cb, 0, cb.length);
// }
// }
// } catch (IOException e) {
// throw new ClassNotFoundException(name, e);
// }
// }
//
// throw new ClassNotFoundException(name);
// }
//
// public static native ByteBuffer getJar(String library, String jarName);
//
// public static native String[] listJars(String library);
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import org.boris.winrun4j.classloader.ByteBufferInputStream;
import org.boris.winrun4j.classloader.EmbeddedClassLoader; | /*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.winrun4j.res;
public class EmbeddedJarURLConnection extends URLConnection
{
protected EmbeddedJarURLConnection(URL url) {
super(url);
}
public void connect() throws IOException {
}
public InputStream getInputStream() throws IOException { | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/ByteBufferInputStream.java
// public class ByteBufferInputStream extends InputStream
// {
// private ByteBuffer bb;
//
// public ByteBufferInputStream(ByteBuffer bb) {
// this.bb = bb;
// }
//
// public int read() throws IOException {
// try {
// return bb.get() & Integer.MAX_VALUE;
// } catch (BufferUnderflowException e) {
// return -1;
// }
// }
//
// public int read(byte[] b) throws IOException {
// int len = b.length;
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, 0, len);
// return len;
// }
//
// public int read(byte[] b, int off, int len) throws IOException {
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, off, len);
// return len;
// }
//
// public long skip(long n) throws IOException {
// if (n > bb.remaining()) {
// n = bb.remaining();
// }
// bb.position((int) (bb.position() + n));
// return n;
// }
//
// public int available() throws IOException {
// return bb.remaining();
// }
//
// public boolean markSupported() {
// return false;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/EmbeddedClassLoader.java
// public class EmbeddedClassLoader extends URLClassLoader
// {
// private String[] jars;
// private ByteBuffer[] buffers;
//
// public EmbeddedClassLoader() {
// super(makeUrls(), ClassLoader.getSystemClassLoader());
// jars = listJars(null);
// buffers = new ByteBuffer[jars.length];
// for (int i = 0; i < buffers.length; i++) {
// buffers[i] = getJar(null, jars[i]);
// }
// }
//
// private static URL[] makeUrls() {
// String p = System.getProperty("java.class.path");
// if (p == null)
// return new URL[0];
// StringTokenizer st = new StringTokenizer(p, ";");
// ArrayList urls = new ArrayList();
// while (st.hasMoreTokens()) {
// try {
// urls.add(new URL(st.nextToken()));
// } catch (MalformedURLException e) {
// }
// }
// return (URL[]) urls.toArray(new URL[0]);
// }
//
// public URL findResource(String name) {
// try {
// return new URL("res:///" + name);
// } catch (MalformedURLException e) {
// return null;
// }
// }
//
// public InputStream getResourceAsStream(String name) {
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// if (name.equals(ze.getName())) {
// return zis;
// }
// }
// } catch (IOException e) {
// return null;
// }
// }
// return null;
// }
//
// protected Class findClass(String name) throws ClassNotFoundException {
// String cname = name.replace('.', '/').concat(".class");
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// String s = ze.getName();
// if (cname.equals(s)) {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// byte[] buf = new byte[4096];
// int len = 0;
// while ((len = zis.read(buf)) > 0) {
// bos.write(buf, 0, len);
// }
// byte[] cb = bos.toByteArray();
// return defineClass(name, cb, 0, cb.length);
// }
// }
// } catch (IOException e) {
// throw new ClassNotFoundException(name, e);
// }
// }
//
// throw new ClassNotFoundException(name);
// }
//
// public static native ByteBuffer getJar(String library, String jarName);
//
// public static native String[] listJars(String library);
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/res/EmbeddedJarURLConnection.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import org.boris.winrun4j.classloader.ByteBufferInputStream;
import org.boris.winrun4j.classloader.EmbeddedClassLoader;
/*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.winrun4j.res;
public class EmbeddedJarURLConnection extends URLConnection
{
protected EmbeddedJarURLConnection(URL url) {
super(url);
}
public void connect() throws IOException {
}
public InputStream getInputStream() throws IOException { | ByteBuffer bb = EmbeddedClassLoader.getJar(null, url.getFile()); |
cthiemann/SPaTo_Visual_Explorer | lib/src/WinRun4J/src/org/boris/winrun4j/res/EmbeddedJarURLConnection.java | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/ByteBufferInputStream.java
// public class ByteBufferInputStream extends InputStream
// {
// private ByteBuffer bb;
//
// public ByteBufferInputStream(ByteBuffer bb) {
// this.bb = bb;
// }
//
// public int read() throws IOException {
// try {
// return bb.get() & Integer.MAX_VALUE;
// } catch (BufferUnderflowException e) {
// return -1;
// }
// }
//
// public int read(byte[] b) throws IOException {
// int len = b.length;
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, 0, len);
// return len;
// }
//
// public int read(byte[] b, int off, int len) throws IOException {
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, off, len);
// return len;
// }
//
// public long skip(long n) throws IOException {
// if (n > bb.remaining()) {
// n = bb.remaining();
// }
// bb.position((int) (bb.position() + n));
// return n;
// }
//
// public int available() throws IOException {
// return bb.remaining();
// }
//
// public boolean markSupported() {
// return false;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/EmbeddedClassLoader.java
// public class EmbeddedClassLoader extends URLClassLoader
// {
// private String[] jars;
// private ByteBuffer[] buffers;
//
// public EmbeddedClassLoader() {
// super(makeUrls(), ClassLoader.getSystemClassLoader());
// jars = listJars(null);
// buffers = new ByteBuffer[jars.length];
// for (int i = 0; i < buffers.length; i++) {
// buffers[i] = getJar(null, jars[i]);
// }
// }
//
// private static URL[] makeUrls() {
// String p = System.getProperty("java.class.path");
// if (p == null)
// return new URL[0];
// StringTokenizer st = new StringTokenizer(p, ";");
// ArrayList urls = new ArrayList();
// while (st.hasMoreTokens()) {
// try {
// urls.add(new URL(st.nextToken()));
// } catch (MalformedURLException e) {
// }
// }
// return (URL[]) urls.toArray(new URL[0]);
// }
//
// public URL findResource(String name) {
// try {
// return new URL("res:///" + name);
// } catch (MalformedURLException e) {
// return null;
// }
// }
//
// public InputStream getResourceAsStream(String name) {
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// if (name.equals(ze.getName())) {
// return zis;
// }
// }
// } catch (IOException e) {
// return null;
// }
// }
// return null;
// }
//
// protected Class findClass(String name) throws ClassNotFoundException {
// String cname = name.replace('.', '/').concat(".class");
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// String s = ze.getName();
// if (cname.equals(s)) {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// byte[] buf = new byte[4096];
// int len = 0;
// while ((len = zis.read(buf)) > 0) {
// bos.write(buf, 0, len);
// }
// byte[] cb = bos.toByteArray();
// return defineClass(name, cb, 0, cb.length);
// }
// }
// } catch (IOException e) {
// throw new ClassNotFoundException(name, e);
// }
// }
//
// throw new ClassNotFoundException(name);
// }
//
// public static native ByteBuffer getJar(String library, String jarName);
//
// public static native String[] listJars(String library);
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import org.boris.winrun4j.classloader.ByteBufferInputStream;
import org.boris.winrun4j.classloader.EmbeddedClassLoader; | /*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.winrun4j.res;
public class EmbeddedJarURLConnection extends URLConnection
{
protected EmbeddedJarURLConnection(URL url) {
super(url);
}
public void connect() throws IOException {
}
public InputStream getInputStream() throws IOException {
ByteBuffer bb = EmbeddedClassLoader.getJar(null, url.getFile());
if (bb == null)
return null;
else | // Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/ByteBufferInputStream.java
// public class ByteBufferInputStream extends InputStream
// {
// private ByteBuffer bb;
//
// public ByteBufferInputStream(ByteBuffer bb) {
// this.bb = bb;
// }
//
// public int read() throws IOException {
// try {
// return bb.get() & Integer.MAX_VALUE;
// } catch (BufferUnderflowException e) {
// return -1;
// }
// }
//
// public int read(byte[] b) throws IOException {
// int len = b.length;
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, 0, len);
// return len;
// }
//
// public int read(byte[] b, int off, int len) throws IOException {
// if (len > bb.remaining()) {
// len = bb.remaining();
// }
//
// bb.get(b, off, len);
// return len;
// }
//
// public long skip(long n) throws IOException {
// if (n > bb.remaining()) {
// n = bb.remaining();
// }
// bb.position((int) (bb.position() + n));
// return n;
// }
//
// public int available() throws IOException {
// return bb.remaining();
// }
//
// public boolean markSupported() {
// return false;
// }
// }
//
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/classloader/EmbeddedClassLoader.java
// public class EmbeddedClassLoader extends URLClassLoader
// {
// private String[] jars;
// private ByteBuffer[] buffers;
//
// public EmbeddedClassLoader() {
// super(makeUrls(), ClassLoader.getSystemClassLoader());
// jars = listJars(null);
// buffers = new ByteBuffer[jars.length];
// for (int i = 0; i < buffers.length; i++) {
// buffers[i] = getJar(null, jars[i]);
// }
// }
//
// private static URL[] makeUrls() {
// String p = System.getProperty("java.class.path");
// if (p == null)
// return new URL[0];
// StringTokenizer st = new StringTokenizer(p, ";");
// ArrayList urls = new ArrayList();
// while (st.hasMoreTokens()) {
// try {
// urls.add(new URL(st.nextToken()));
// } catch (MalformedURLException e) {
// }
// }
// return (URL[]) urls.toArray(new URL[0]);
// }
//
// public URL findResource(String name) {
// try {
// return new URL("res:///" + name);
// } catch (MalformedURLException e) {
// return null;
// }
// }
//
// public InputStream getResourceAsStream(String name) {
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// if (name.equals(ze.getName())) {
// return zis;
// }
// }
// } catch (IOException e) {
// return null;
// }
// }
// return null;
// }
//
// protected Class findClass(String name) throws ClassNotFoundException {
// String cname = name.replace('.', '/').concat(".class");
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer bb = buffers[i];
// bb.position(0);
// ZipInputStream zis = new ZipInputStream(new ByteBufferInputStream(bb));
// ZipEntry ze = null;
// try {
// while ((ze = zis.getNextEntry()) != null) {
// String s = ze.getName();
// if (cname.equals(s)) {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// byte[] buf = new byte[4096];
// int len = 0;
// while ((len = zis.read(buf)) > 0) {
// bos.write(buf, 0, len);
// }
// byte[] cb = bos.toByteArray();
// return defineClass(name, cb, 0, cb.length);
// }
// }
// } catch (IOException e) {
// throw new ClassNotFoundException(name, e);
// }
// }
//
// throw new ClassNotFoundException(name);
// }
//
// public static native ByteBuffer getJar(String library, String jarName);
//
// public static native String[] listJars(String library);
// }
// Path: lib/src/WinRun4J/src/org/boris/winrun4j/res/EmbeddedJarURLConnection.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import org.boris.winrun4j.classloader.ByteBufferInputStream;
import org.boris.winrun4j.classloader.EmbeddedClassLoader;
/*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.winrun4j.res;
public class EmbeddedJarURLConnection extends URLConnection
{
protected EmbeddedJarURLConnection(URL url) {
super(url);
}
public void connect() throws IOException {
}
public InputStream getInputStream() throws IOException {
ByteBuffer bb = EmbeddedClassLoader.getJar(null, url.getFile());
if (bb == null)
return null;
else | return new ByteBufferInputStream(bb); |
CalebKussmaul/GIFKR | src/gui/PreviewPanel.java | // Path: src/kussmaulUtils/Refreshable.java
// public interface Refreshable {
//
// public void refresh();
// }
| import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.image.BufferedImage;
import javax.swing.*;
import kussmaulUtils.Refreshable; | package gui;
public class PreviewPanel extends JPanel {
private static final long serialVersionUID = -5318410876577677115L; | // Path: src/kussmaulUtils/Refreshable.java
// public interface Refreshable {
//
// public void refresh();
// }
// Path: src/gui/PreviewPanel.java
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.image.BufferedImage;
import javax.swing.*;
import kussmaulUtils.Refreshable;
package gui;
public class PreviewPanel extends JPanel {
private static final long serialVersionUID = -5318410876577677115L; | private Refreshable r; |
CalebKussmaul/GIFKR | src/interpolation/TempMain.java | // Path: src/filter/base/ImageFilter.java
// public abstract class ImageFilter implements Comparable<ImageFilter> {
//
// @ControlOverride(max = "360")
// public double angle = 0;
// @ControlOverride(animationControl = ControlType.STATIC)
// public static boolean rotateCorrection;
// @ControlOverride(animationControl = ControlType.STATIC)
// public boolean randomizeSeed = true;
// @ControlOverride(animationControl = ControlType.STATIC)
// public int randomSeed = 8675309;
//
// protected final Random rand;
//
// protected List<Field> hiddenFields;
//
// private FieldControlsPanel p;
//
// public ImageFilter() {
// rand = new Random(randomSeed);
// hiddenFields = new ArrayList<>();
//
// if(!randomControls())
// hideRandom();
// if(!angleControls())
// hideAngle();
// }
//
// protected boolean randomControls() {
// return true;
// }
//
// protected boolean angleControls() {
// return true;
// }
//
// protected abstract BufferedImage apply(BufferedImage img);
// public String getCategory() {
// return "General";
// }
//
// protected void beforeFilter() {
//
// }
//
// protected void afterFilter() {
// }
//
// public final BufferedImage getFilteredImage(BufferedImage img) {
//
// randomSeed = randomizeSeed ? (int) (Math.random() * Integer.MAX_VALUE) : randomSeed;
// rand.setSeed(randomSeed);
//
// beforeFilter();
//
// BufferedImage filtered = apply(ImageTools.rotate(img, angle, false));
// img = ImageTools.unrotate(filtered, angle, img.getWidth(), img.getHeight(), rotateCorrection, false);
//
// afterFilter();
//
// return img;
// }
//
// public final FieldControlsPanel getSettingsPanel() {
// return p;
// }
//
// public final FieldControlsPanel getSettingsPanel(Refreshable r, boolean channel) {
//
// if(p != null)
// return p;
//
// List<Field> fields = getPublicFields(new ArrayList<Field>(), getClass());
// ArrayList<FieldControl> controlComponents = new ArrayList<FieldControl>();
//
// for(Field f : fields) {
// try {
// controlComponents.add(new FieldControl(f, this, ce -> {r.refresh();}));
// } catch (Exception e) {
// e.printStackTrace();
// System.err.println("No control for "+f.getType().getName() +".class in "+this.getClass().getSimpleName()+".class");
// }
// }
//
// p = new FieldControlsPanel(controlComponents, StringUtil.deCamel(this.getClass().getSimpleName())+" settings", channel);
//
// return p;
// }
//
// @Override
// public String toString() {
// return (getCategory() == null ? "" : getCategory()+" - ") + StringUtil.deCamel(getClass().getSimpleName().replaceAll("(\\s?Filter$)", ""));
// }
//
// @Override
// public final int compareTo(ImageFilter o) {
// if(getCategory() == null ^ o.getCategory() == null)
// return getCategory() == null ? -1 : 1;
//
// return toString().compareTo(o.toString());
// }
//
// protected final void hideRandom() {
// try {
// hide(this.getClass().getField("randomizeSeed"));
// hide(this.getClass().getField("randomSeed"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hideAngle() {
// try {
// hide(this.getClass().getField("angle"));
// hide(this.getClass().getField("rotateCorrection"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hide(Field f) {
// hiddenFields.add(f);
// }
//
// private List<Field> getPublicFields(List<Field> fields, Class<?> type) {
// fields.addAll(Arrays.asList(type.getDeclaredFields()));
//
// for(int i = 0; i < fields.size(); i++) {
// int mod = fields.get(i).getModifiers();
// if(!Modifier.isPublic(mod) || Modifier.isFinal(mod) || hiddenFields.contains(fields.get(i))) {
// fields.remove(i);
// i--;
// }
// }
// if (type.getSuperclass() != null) {
// fields = getPublicFields(fields, type.getSuperclass());
// }
// return fields;
// }
//
// @Override
// public final boolean equals(Object o) {
// return this.getClass() == o.getClass();
// }
//
// public void setX(float x) {
// if(p != null)
// p.setX(x);
// }
// }
//
// Path: src/filter/filters/AddFilter.java
// public class AddFilter extends AlgebraicImageFilter {
//
// @ControlOverride(max = "255")
// public int constant;
//
//
// @Override
// protected boolean randomControls() {
// return false;
// }
//
// @Override
// public int apply(int channel) {
// return channel + constant;
// }
//
// @Override
// protected boolean useLookupTable() {
// return true;
// }
// }
| import filter.base.ImageFilter;
import filter.filters.AddFilter; | package interpolation;
public class TempMain {
public static void main(String[] args){ | // Path: src/filter/base/ImageFilter.java
// public abstract class ImageFilter implements Comparable<ImageFilter> {
//
// @ControlOverride(max = "360")
// public double angle = 0;
// @ControlOverride(animationControl = ControlType.STATIC)
// public static boolean rotateCorrection;
// @ControlOverride(animationControl = ControlType.STATIC)
// public boolean randomizeSeed = true;
// @ControlOverride(animationControl = ControlType.STATIC)
// public int randomSeed = 8675309;
//
// protected final Random rand;
//
// protected List<Field> hiddenFields;
//
// private FieldControlsPanel p;
//
// public ImageFilter() {
// rand = new Random(randomSeed);
// hiddenFields = new ArrayList<>();
//
// if(!randomControls())
// hideRandom();
// if(!angleControls())
// hideAngle();
// }
//
// protected boolean randomControls() {
// return true;
// }
//
// protected boolean angleControls() {
// return true;
// }
//
// protected abstract BufferedImage apply(BufferedImage img);
// public String getCategory() {
// return "General";
// }
//
// protected void beforeFilter() {
//
// }
//
// protected void afterFilter() {
// }
//
// public final BufferedImage getFilteredImage(BufferedImage img) {
//
// randomSeed = randomizeSeed ? (int) (Math.random() * Integer.MAX_VALUE) : randomSeed;
// rand.setSeed(randomSeed);
//
// beforeFilter();
//
// BufferedImage filtered = apply(ImageTools.rotate(img, angle, false));
// img = ImageTools.unrotate(filtered, angle, img.getWidth(), img.getHeight(), rotateCorrection, false);
//
// afterFilter();
//
// return img;
// }
//
// public final FieldControlsPanel getSettingsPanel() {
// return p;
// }
//
// public final FieldControlsPanel getSettingsPanel(Refreshable r, boolean channel) {
//
// if(p != null)
// return p;
//
// List<Field> fields = getPublicFields(new ArrayList<Field>(), getClass());
// ArrayList<FieldControl> controlComponents = new ArrayList<FieldControl>();
//
// for(Field f : fields) {
// try {
// controlComponents.add(new FieldControl(f, this, ce -> {r.refresh();}));
// } catch (Exception e) {
// e.printStackTrace();
// System.err.println("No control for "+f.getType().getName() +".class in "+this.getClass().getSimpleName()+".class");
// }
// }
//
// p = new FieldControlsPanel(controlComponents, StringUtil.deCamel(this.getClass().getSimpleName())+" settings", channel);
//
// return p;
// }
//
// @Override
// public String toString() {
// return (getCategory() == null ? "" : getCategory()+" - ") + StringUtil.deCamel(getClass().getSimpleName().replaceAll("(\\s?Filter$)", ""));
// }
//
// @Override
// public final int compareTo(ImageFilter o) {
// if(getCategory() == null ^ o.getCategory() == null)
// return getCategory() == null ? -1 : 1;
//
// return toString().compareTo(o.toString());
// }
//
// protected final void hideRandom() {
// try {
// hide(this.getClass().getField("randomizeSeed"));
// hide(this.getClass().getField("randomSeed"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hideAngle() {
// try {
// hide(this.getClass().getField("angle"));
// hide(this.getClass().getField("rotateCorrection"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hide(Field f) {
// hiddenFields.add(f);
// }
//
// private List<Field> getPublicFields(List<Field> fields, Class<?> type) {
// fields.addAll(Arrays.asList(type.getDeclaredFields()));
//
// for(int i = 0; i < fields.size(); i++) {
// int mod = fields.get(i).getModifiers();
// if(!Modifier.isPublic(mod) || Modifier.isFinal(mod) || hiddenFields.contains(fields.get(i))) {
// fields.remove(i);
// i--;
// }
// }
// if (type.getSuperclass() != null) {
// fields = getPublicFields(fields, type.getSuperclass());
// }
// return fields;
// }
//
// @Override
// public final boolean equals(Object o) {
// return this.getClass() == o.getClass();
// }
//
// public void setX(float x) {
// if(p != null)
// p.setX(x);
// }
// }
//
// Path: src/filter/filters/AddFilter.java
// public class AddFilter extends AlgebraicImageFilter {
//
// @ControlOverride(max = "255")
// public int constant;
//
//
// @Override
// protected boolean randomControls() {
// return false;
// }
//
// @Override
// public int apply(int channel) {
// return channel + constant;
// }
//
// @Override
// protected boolean useLookupTable() {
// return true;
// }
// }
// Path: src/interpolation/TempMain.java
import filter.base.ImageFilter;
import filter.filters.AddFilter;
package interpolation;
public class TempMain {
public static void main(String[] args){ | System.out.println(AddFilter.class.isAssignableFrom(ImageFilter.class)); |
CalebKussmaul/GIFKR | src/interpolation/TempMain.java | // Path: src/filter/base/ImageFilter.java
// public abstract class ImageFilter implements Comparable<ImageFilter> {
//
// @ControlOverride(max = "360")
// public double angle = 0;
// @ControlOverride(animationControl = ControlType.STATIC)
// public static boolean rotateCorrection;
// @ControlOverride(animationControl = ControlType.STATIC)
// public boolean randomizeSeed = true;
// @ControlOverride(animationControl = ControlType.STATIC)
// public int randomSeed = 8675309;
//
// protected final Random rand;
//
// protected List<Field> hiddenFields;
//
// private FieldControlsPanel p;
//
// public ImageFilter() {
// rand = new Random(randomSeed);
// hiddenFields = new ArrayList<>();
//
// if(!randomControls())
// hideRandom();
// if(!angleControls())
// hideAngle();
// }
//
// protected boolean randomControls() {
// return true;
// }
//
// protected boolean angleControls() {
// return true;
// }
//
// protected abstract BufferedImage apply(BufferedImage img);
// public String getCategory() {
// return "General";
// }
//
// protected void beforeFilter() {
//
// }
//
// protected void afterFilter() {
// }
//
// public final BufferedImage getFilteredImage(BufferedImage img) {
//
// randomSeed = randomizeSeed ? (int) (Math.random() * Integer.MAX_VALUE) : randomSeed;
// rand.setSeed(randomSeed);
//
// beforeFilter();
//
// BufferedImage filtered = apply(ImageTools.rotate(img, angle, false));
// img = ImageTools.unrotate(filtered, angle, img.getWidth(), img.getHeight(), rotateCorrection, false);
//
// afterFilter();
//
// return img;
// }
//
// public final FieldControlsPanel getSettingsPanel() {
// return p;
// }
//
// public final FieldControlsPanel getSettingsPanel(Refreshable r, boolean channel) {
//
// if(p != null)
// return p;
//
// List<Field> fields = getPublicFields(new ArrayList<Field>(), getClass());
// ArrayList<FieldControl> controlComponents = new ArrayList<FieldControl>();
//
// for(Field f : fields) {
// try {
// controlComponents.add(new FieldControl(f, this, ce -> {r.refresh();}));
// } catch (Exception e) {
// e.printStackTrace();
// System.err.println("No control for "+f.getType().getName() +".class in "+this.getClass().getSimpleName()+".class");
// }
// }
//
// p = new FieldControlsPanel(controlComponents, StringUtil.deCamel(this.getClass().getSimpleName())+" settings", channel);
//
// return p;
// }
//
// @Override
// public String toString() {
// return (getCategory() == null ? "" : getCategory()+" - ") + StringUtil.deCamel(getClass().getSimpleName().replaceAll("(\\s?Filter$)", ""));
// }
//
// @Override
// public final int compareTo(ImageFilter o) {
// if(getCategory() == null ^ o.getCategory() == null)
// return getCategory() == null ? -1 : 1;
//
// return toString().compareTo(o.toString());
// }
//
// protected final void hideRandom() {
// try {
// hide(this.getClass().getField("randomizeSeed"));
// hide(this.getClass().getField("randomSeed"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hideAngle() {
// try {
// hide(this.getClass().getField("angle"));
// hide(this.getClass().getField("rotateCorrection"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hide(Field f) {
// hiddenFields.add(f);
// }
//
// private List<Field> getPublicFields(List<Field> fields, Class<?> type) {
// fields.addAll(Arrays.asList(type.getDeclaredFields()));
//
// for(int i = 0; i < fields.size(); i++) {
// int mod = fields.get(i).getModifiers();
// if(!Modifier.isPublic(mod) || Modifier.isFinal(mod) || hiddenFields.contains(fields.get(i))) {
// fields.remove(i);
// i--;
// }
// }
// if (type.getSuperclass() != null) {
// fields = getPublicFields(fields, type.getSuperclass());
// }
// return fields;
// }
//
// @Override
// public final boolean equals(Object o) {
// return this.getClass() == o.getClass();
// }
//
// public void setX(float x) {
// if(p != null)
// p.setX(x);
// }
// }
//
// Path: src/filter/filters/AddFilter.java
// public class AddFilter extends AlgebraicImageFilter {
//
// @ControlOverride(max = "255")
// public int constant;
//
//
// @Override
// protected boolean randomControls() {
// return false;
// }
//
// @Override
// public int apply(int channel) {
// return channel + constant;
// }
//
// @Override
// protected boolean useLookupTable() {
// return true;
// }
// }
| import filter.base.ImageFilter;
import filter.filters.AddFilter; | package interpolation;
public class TempMain {
public static void main(String[] args){ | // Path: src/filter/base/ImageFilter.java
// public abstract class ImageFilter implements Comparable<ImageFilter> {
//
// @ControlOverride(max = "360")
// public double angle = 0;
// @ControlOverride(animationControl = ControlType.STATIC)
// public static boolean rotateCorrection;
// @ControlOverride(animationControl = ControlType.STATIC)
// public boolean randomizeSeed = true;
// @ControlOverride(animationControl = ControlType.STATIC)
// public int randomSeed = 8675309;
//
// protected final Random rand;
//
// protected List<Field> hiddenFields;
//
// private FieldControlsPanel p;
//
// public ImageFilter() {
// rand = new Random(randomSeed);
// hiddenFields = new ArrayList<>();
//
// if(!randomControls())
// hideRandom();
// if(!angleControls())
// hideAngle();
// }
//
// protected boolean randomControls() {
// return true;
// }
//
// protected boolean angleControls() {
// return true;
// }
//
// protected abstract BufferedImage apply(BufferedImage img);
// public String getCategory() {
// return "General";
// }
//
// protected void beforeFilter() {
//
// }
//
// protected void afterFilter() {
// }
//
// public final BufferedImage getFilteredImage(BufferedImage img) {
//
// randomSeed = randomizeSeed ? (int) (Math.random() * Integer.MAX_VALUE) : randomSeed;
// rand.setSeed(randomSeed);
//
// beforeFilter();
//
// BufferedImage filtered = apply(ImageTools.rotate(img, angle, false));
// img = ImageTools.unrotate(filtered, angle, img.getWidth(), img.getHeight(), rotateCorrection, false);
//
// afterFilter();
//
// return img;
// }
//
// public final FieldControlsPanel getSettingsPanel() {
// return p;
// }
//
// public final FieldControlsPanel getSettingsPanel(Refreshable r, boolean channel) {
//
// if(p != null)
// return p;
//
// List<Field> fields = getPublicFields(new ArrayList<Field>(), getClass());
// ArrayList<FieldControl> controlComponents = new ArrayList<FieldControl>();
//
// for(Field f : fields) {
// try {
// controlComponents.add(new FieldControl(f, this, ce -> {r.refresh();}));
// } catch (Exception e) {
// e.printStackTrace();
// System.err.println("No control for "+f.getType().getName() +".class in "+this.getClass().getSimpleName()+".class");
// }
// }
//
// p = new FieldControlsPanel(controlComponents, StringUtil.deCamel(this.getClass().getSimpleName())+" settings", channel);
//
// return p;
// }
//
// @Override
// public String toString() {
// return (getCategory() == null ? "" : getCategory()+" - ") + StringUtil.deCamel(getClass().getSimpleName().replaceAll("(\\s?Filter$)", ""));
// }
//
// @Override
// public final int compareTo(ImageFilter o) {
// if(getCategory() == null ^ o.getCategory() == null)
// return getCategory() == null ? -1 : 1;
//
// return toString().compareTo(o.toString());
// }
//
// protected final void hideRandom() {
// try {
// hide(this.getClass().getField("randomizeSeed"));
// hide(this.getClass().getField("randomSeed"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hideAngle() {
// try {
// hide(this.getClass().getField("angle"));
// hide(this.getClass().getField("rotateCorrection"));
// } catch (NoSuchFieldException | SecurityException e) {
// e.printStackTrace();
// }
// }
//
// protected final void hide(Field f) {
// hiddenFields.add(f);
// }
//
// private List<Field> getPublicFields(List<Field> fields, Class<?> type) {
// fields.addAll(Arrays.asList(type.getDeclaredFields()));
//
// for(int i = 0; i < fields.size(); i++) {
// int mod = fields.get(i).getModifiers();
// if(!Modifier.isPublic(mod) || Modifier.isFinal(mod) || hiddenFields.contains(fields.get(i))) {
// fields.remove(i);
// i--;
// }
// }
// if (type.getSuperclass() != null) {
// fields = getPublicFields(fields, type.getSuperclass());
// }
// return fields;
// }
//
// @Override
// public final boolean equals(Object o) {
// return this.getClass() == o.getClass();
// }
//
// public void setX(float x) {
// if(p != null)
// p.setX(x);
// }
// }
//
// Path: src/filter/filters/AddFilter.java
// public class AddFilter extends AlgebraicImageFilter {
//
// @ControlOverride(max = "255")
// public int constant;
//
//
// @Override
// protected boolean randomControls() {
// return false;
// }
//
// @Override
// public int apply(int channel) {
// return channel + constant;
// }
//
// @Override
// protected boolean useLookupTable() {
// return true;
// }
// }
// Path: src/interpolation/TempMain.java
import filter.base.ImageFilter;
import filter.filters.AddFilter;
package interpolation;
public class TempMain {
public static void main(String[] args){ | System.out.println(AddFilter.class.isAssignableFrom(ImageFilter.class)); |
CalebKussmaul/GIFKR | src/interpolation/FloatInterpolator.java | // Path: src/gui/TransferableUtils.java
// public class TransferableUtils {
//
// public static void copy(Image image) {
//
// ImageTransferable transferable = new ImageTransferable(image);
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
// }
//
// static class ImageTransferable implements Transferable {
// private Image image;
//
// public ImageTransferable (Image image) {
// this.image = image;
// }
//
// public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
// if (isDataFlavorSupported(flavor)) {
// return image;
// }
// else {
// throw new UnsupportedFlavorException(flavor);
// }
// }
//
// public boolean isDataFlavorSupported (DataFlavor flavor){
// return flavor.equals(DataFlavor.imageFlavor);
// }
//
// public DataFlavor[] getTransferDataFlavors () {
// return new DataFlavor[] { DataFlavor.imageFlavor};
// }
// }
//
// public static void copyObject(Serializable object) {
// ObjectTransferable transferable = new ObjectTransferable(object);
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
//
// }
//
// public static DataFlavor objectDataFlavor = new DataFlavor(Serializable.class, "Object");
//
// public static class ObjectTransferable implements Transferable {
//
// private Serializable object;
//
// public ObjectTransferable(Serializable object) {
// this.object = object;
// }
//
// @Override
// public DataFlavor[] getTransferDataFlavors() {
// return new DataFlavor[] {objectDataFlavor};
// }
//
// @Override
// public boolean isDataFlavorSupported(DataFlavor flavor) {
// return flavor.equals(objectDataFlavor);
// }
//
// @Override
// public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
// return object;
// }
// }
// }
| import java.awt.*;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.geom.GeneralPath;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import gui.TransferableUtils; | fireChangeEvent();
});
equationField.addActionListener(ae -> {
if(function.setFunction(equationField.getText())) {
clear(0, 1);
equationField.setBackground(new Color(255, 255, 255, 255));
for(float f = 0; f <= 1; f+=.02f)
keyframes.add(new Keyframe<Float>(f, Math.min(1f, Math.max(0f, function.evalF(f)))));
keyframes.add(new Keyframe<Float>(1f, Math.min(1f, Math.max(0f, function.evalF(1f)))));
for (int i = 1; i < keyframes.size()-1; i++) {
if(keyframes.get(i-1).getValue().equals(keyframes.get(i).getValue()) && keyframes.get(i).getValue().equals(keyframes.get(i+1).getValue())) {
keyframes.remove(i);
i--;
}
}
repaint();
fireChangeEvent();
animationButton.repaint();
}
else {
equationField.setBackground(new Color(255, 127, 127));
}
});
}
@SuppressWarnings("unchecked")
private void createMenuBar() {
JMenuItem copy = new JMenuItem("Copy"); | // Path: src/gui/TransferableUtils.java
// public class TransferableUtils {
//
// public static void copy(Image image) {
//
// ImageTransferable transferable = new ImageTransferable(image);
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
// }
//
// static class ImageTransferable implements Transferable {
// private Image image;
//
// public ImageTransferable (Image image) {
// this.image = image;
// }
//
// public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
// if (isDataFlavorSupported(flavor)) {
// return image;
// }
// else {
// throw new UnsupportedFlavorException(flavor);
// }
// }
//
// public boolean isDataFlavorSupported (DataFlavor flavor){
// return flavor.equals(DataFlavor.imageFlavor);
// }
//
// public DataFlavor[] getTransferDataFlavors () {
// return new DataFlavor[] { DataFlavor.imageFlavor};
// }
// }
//
// public static void copyObject(Serializable object) {
// ObjectTransferable transferable = new ObjectTransferable(object);
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, null);
//
// }
//
// public static DataFlavor objectDataFlavor = new DataFlavor(Serializable.class, "Object");
//
// public static class ObjectTransferable implements Transferable {
//
// private Serializable object;
//
// public ObjectTransferable(Serializable object) {
// this.object = object;
// }
//
// @Override
// public DataFlavor[] getTransferDataFlavors() {
// return new DataFlavor[] {objectDataFlavor};
// }
//
// @Override
// public boolean isDataFlavorSupported(DataFlavor flavor) {
// return flavor.equals(objectDataFlavor);
// }
//
// @Override
// public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
// return object;
// }
// }
// }
// Path: src/interpolation/FloatInterpolator.java
import java.awt.*;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.geom.GeneralPath;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import gui.TransferableUtils;
fireChangeEvent();
});
equationField.addActionListener(ae -> {
if(function.setFunction(equationField.getText())) {
clear(0, 1);
equationField.setBackground(new Color(255, 255, 255, 255));
for(float f = 0; f <= 1; f+=.02f)
keyframes.add(new Keyframe<Float>(f, Math.min(1f, Math.max(0f, function.evalF(f)))));
keyframes.add(new Keyframe<Float>(1f, Math.min(1f, Math.max(0f, function.evalF(1f)))));
for (int i = 1; i < keyframes.size()-1; i++) {
if(keyframes.get(i-1).getValue().equals(keyframes.get(i).getValue()) && keyframes.get(i).getValue().equals(keyframes.get(i+1).getValue())) {
keyframes.remove(i);
i--;
}
}
repaint();
fireChangeEvent();
animationButton.repaint();
}
else {
equationField.setBackground(new Color(255, 127, 127));
}
});
}
@SuppressWarnings("unchecked")
private void createMenuBar() {
JMenuItem copy = new JMenuItem("Copy"); | copy.addActionListener(ae -> TransferableUtils.copyObject(Keyframe.deepCopy(keyframes))); |
CalebKussmaul/GIFKR | src/gui/PreviewStatusPanel.java | // Path: src/kussmaulUtils/Refreshable.java
// public interface Refreshable {
//
// public void refresh();
// }
| import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingUtilities;
import kussmaulUtils.Refreshable; | package gui;
public class PreviewStatusPanel extends JPanel {
private static final long serialVersionUID = -7198039609391537335L;
private static String format = "Time: %1$9s | Resolution: %2$9s | Original: %3$9s";
private static String formatGif = "Time: %1$9s | Resolution: %2$9s | Original: %3$9s | Frame: %4$9s";
| // Path: src/kussmaulUtils/Refreshable.java
// public interface Refreshable {
//
// public void refresh();
// }
// Path: src/gui/PreviewStatusPanel.java
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingUtilities;
import kussmaulUtils.Refreshable;
package gui;
public class PreviewStatusPanel extends JPanel {
private static final long serialVersionUID = -7198039609391537335L;
private static String format = "Time: %1$9s | Resolution: %2$9s | Original: %3$9s";
private static String formatGif = "Time: %1$9s | Resolution: %2$9s | Original: %3$9s | Frame: %4$9s";
| private Refreshable r; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/AddressMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Address.java
// @Data
// @NoArgsConstructor
// public class Address {
// private Long addrId;
//
// private String street;
//
// private String city;
//
// private String state;
//
// private String zip;
//
// private String country;
//
// public static void main(String[] args) throws InterruptedException {
// CompletableFuture.supplyAsync(()-> {
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// System.out.println(Thread.currentThread().getName());
// return 8;
// }).thenApplyAsync( t -> {
// System.out.println(Thread.currentThread().getName());
// return t*t;
// })
// .thenAccept(t ->{
// System.out.println(Thread.currentThread().getName());
// System.out.println(t);
// });
//
// System.out.println("main");
// TimeUnit.HOURS.sleep(1L);
// }
//
//
// }
| import com.sdcuike.practice.domain.Address; | package com.sdcuike.practice.mapper;
public interface AddressMapper {
int deleteByPrimaryKey(Long addrId);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Address.java
// @Data
// @NoArgsConstructor
// public class Address {
// private Long addrId;
//
// private String street;
//
// private String city;
//
// private String state;
//
// private String zip;
//
// private String country;
//
// public static void main(String[] args) throws InterruptedException {
// CompletableFuture.supplyAsync(()-> {
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// System.out.println(Thread.currentThread().getName());
// return 8;
// }).thenApplyAsync( t -> {
// System.out.println(Thread.currentThread().getName());
// return t*t;
// })
// .thenAccept(t ->{
// System.out.println(Thread.currentThread().getName());
// System.out.println(t);
// });
//
// System.out.println("main");
// TimeUnit.HOURS.sleep(1L);
// }
//
//
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/AddressMapper.java
import com.sdcuike.practice.domain.Address;
package com.sdcuike.practice.mapper;
public interface AddressMapper {
int deleteByPrimaryKey(Long addrId);
| int insert(Address record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
| import com.sdcuike.practice.domain.City;
import lombok.Data;
import javax.validation.constraints.NotNull; | package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/4/14.
*/
@Data
public class InsertCityRequestDto {
@NotNull
private String name;
@NotNull
private String state;
public static void main(String[] args) { | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
import com.sdcuike.practice.domain.City;
import lombok.Data;
import javax.validation.constraints.NotNull;
package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/4/14.
*/
@Data
public class InsertCityRequestDto {
@NotNull
private String name;
@NotNull
private String state;
public static void main(String[] args) { | City city = new City(); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/AuthorityMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Authority; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface AuthorityMapper {
int deleteByPrimaryKey(String name);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/AuthorityMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Authority;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface AuthorityMapper {
int deleteByPrimaryKey(String name);
| int insert(Authority record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
| import com.sdcuike.practice.domain.StudentWithBLOBs;
import org.mapstruct.Mapper; | package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/5/2.s
*/
@Mapper(uses = {AddressDtoMapper.class})
public interface StudentDtoMapper {
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
import com.sdcuike.practice.domain.StudentWithBLOBs;
import org.mapstruct.Mapper;
package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/5/2.s
*/
@Mapper(uses = {AddressDtoMapper.class})
public interface StudentDtoMapper {
| StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.City; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface CityMapper {
int deleteByPrimaryKey(Long id);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.City;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface CityMapper {
int deleteByPrimaryKey(Long id);
| int insert(City record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.User; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface UserMapper {
int deleteByPrimaryKey(Long id);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.User;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface UserMapper {
int deleteByPrimaryKey(Long id);
| int insert(User record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired | private StudentMapper studentMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired
private StudentMapper studentMapper;
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired
private StudentMapper studentMapper;
@Autowired | private StudentDtoMapper studentDtoMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired
private StudentMapper studentMapper;
@Autowired
private StudentDtoMapper studentDtoMapper;
@GetMapping("/{id}") | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired
private StudentMapper studentMapper;
@Autowired
private StudentDtoMapper studentDtoMapper;
@GetMapping("/{id}") | public ModelResult<StudentDto> queryById(@PathVariable("id") Long id) { |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired
private StudentMapper studentMapper;
@Autowired
private StudentDtoMapper studentDtoMapper;
@GetMapping("/{id}")
public ModelResult<StudentDto> queryById(@PathVariable("id") Long id) {
ModelResult<StudentDto> result = new ModelResult<>();
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDto.java
// @Data
// @NoArgsConstructor
// public class StudentDto {
//
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<AddressDto> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/StudentDtoMapper.java
// @Mapper(uses = {AddressDtoMapper.class})
// public interface StudentDtoMapper {
//
// StudentDto student2Dto(StudentWithBLOBs studentWithBLOBs);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/StudentController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.StudentWithBLOBs;
import com.sdcuike.practice.domain.dto.StudentDto;
import com.sdcuike.practice.domain.dto.StudentDtoMapper;
import com.sdcuike.practice.mapper.StudentMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/5/2.
*/
@RestController
@RequestMapping(path = "/student", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class StudentController {
@Autowired
private StudentMapper studentMapper;
@Autowired
private StudentDtoMapper studentDtoMapper;
@GetMapping("/{id}")
public ModelResult<StudentDto> queryById(@PathVariable("id") Long id) {
ModelResult<StudentDto> result = new ModelResult<>();
| StudentWithBLOBs studentWithBLOBs = studentMapper.selectByPrimaryKey(id); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/controller/ExampleController.java | // Path: spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/feign/ExampleServiceFeignClient.java
// @FeignClient(name = "exampleService",
// url = "${exampleService.ribbon.listOfServers}",
// configuration = {OAuth2FeignAutoConfiguration.class})
// @RequestMapping(value = "/springBoot/example"
// , consumes = MediaType.APPLICATION_JSON_UTF8_VALUE
// , produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
// public interface ExampleServiceFeignClient {
// @GetMapping("/")
// ModelResult<String> home();
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.feign.ExampleServiceFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; | package com.sdcuike.practice.controller;
@RestController
@RequestMapping(path = "/api/example", produces = MediaType.APPLICATION_JSON_VALUE)
public class ExampleController {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired | // Path: spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/feign/ExampleServiceFeignClient.java
// @FeignClient(name = "exampleService",
// url = "${exampleService.ribbon.listOfServers}",
// configuration = {OAuth2FeignAutoConfiguration.class})
// @RequestMapping(value = "/springBoot/example"
// , consumes = MediaType.APPLICATION_JSON_UTF8_VALUE
// , produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
// public interface ExampleServiceFeignClient {
// @GetMapping("/")
// ModelResult<String> home();
// }
// Path: spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/controller/ExampleController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.feign.ExampleServiceFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package com.sdcuike.practice.controller;
@RestController
@RequestMapping(path = "/api/example", produces = MediaType.APPLICATION_JSON_VALUE)
public class ExampleController {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired | private ExampleServiceFeignClient exampleServiceFeignClient; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired | private CityMapper cityMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired | private CityDtoMapper cityDtoMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired
private CityDtoMapper cityDtoMapper;
/**
* 城市收录
*
* @param insertCityRequestDto
* @return
*/
@PutMapping("/insert") | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired
private CityDtoMapper cityDtoMapper;
/**
* 城市收录
*
* @param insertCityRequestDto
* @return
*/
@PutMapping("/insert") | public ModelResult<City> insertCity(@Validated @RequestBody InsertCityRequestDto insertCityRequestDto) { |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired
private CityDtoMapper cityDtoMapper;
/**
* 城市收录
*
* @param insertCityRequestDto
* @return
*/
@PutMapping("/insert") | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired
private CityDtoMapper cityDtoMapper;
/**
* 城市收录
*
* @param insertCityRequestDto
* @return
*/
@PutMapping("/insert") | public ModelResult<City> insertCity(@Validated @RequestBody InsertCityRequestDto insertCityRequestDto) { |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; | package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired
private CityDtoMapper cityDtoMapper;
/**
* 城市收录
*
* @param insertCityRequestDto
* @return
*/
@PutMapping("/insert")
public ModelResult<City> insertCity(@Validated @RequestBody InsertCityRequestDto insertCityRequestDto) {
ModelResult<City> modelResult = new ModelResult<>();
City city = cityDtoMapper.cityDto2City(insertCityRequestDto);
int count = cityMapper.insert(city);
if (count == 1) {
modelResult.setData(city);
} else {
modelResult.setReturnCode("-1");
modelResult.setReturnMsg("操作数据库失败");
}
return modelResult;
}
@PostMapping("/update") | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
// @Mapper
// public interface CityDtoMapper {
// InsertCityRequestDto cityToDto(City city);
// City cityDto2City(InsertCityRequestDto insertCityRequestDto);
// City cityDto2City(UpdateCityRequestDto updateCityRequestDto);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/InsertCityRequestDto.java
// @Data
// public class InsertCityRequestDto {
// @NotNull
// private String name;
//
// @NotNull
// private String state;
//
//
// public static void main(String[] args) {
// City city = new City();
// city.setId(12L);
// city.setName("na");
// city.setState("shandong");
// CityDtoMapper cityDtoMapper = new CityDtoMapperImpl();
// InsertCityRequestDto insertCityRequestDto = cityDtoMapper.cityToDto(city);
// System.out.println(insertCityRequestDto);
// }
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/UpdateCityRequestDto.java
// @Data
// @NoArgsConstructor
// public class UpdateCityRequestDto {
// @NotNull
// private Long id;
//
// private String name;
//
// private String state;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CityMapper.java
// @UseDataSourceTest
// public interface CityMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(City record);
//
// int insertSelective(City record);
//
// City selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(City record);
//
// int updateByPrimaryKey(City record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/CityController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.City;
import com.sdcuike.practice.domain.dto.CityDtoMapper;
import com.sdcuike.practice.domain.dto.InsertCityRequestDto;
import com.sdcuike.practice.domain.dto.UpdateCityRequestDto;
import com.sdcuike.practice.mapper.CityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
package com.sdcuike.practice.controller;
/**
* Created by beaver on 2017/4/25.
*/
@RestController
@RequestMapping(path = "/city", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class CityController {
@Autowired
private CityMapper cityMapper;
@Autowired
private CityDtoMapper cityDtoMapper;
/**
* 城市收录
*
* @param insertCityRequestDto
* @return
*/
@PutMapping("/insert")
public ModelResult<City> insertCity(@Validated @RequestBody InsertCityRequestDto insertCityRequestDto) {
ModelResult<City> modelResult = new ModelResult<>();
City city = cityDtoMapper.cityDto2City(insertCityRequestDto);
int count = cityMapper.insert(city);
if (count == 1) {
modelResult.setData(city);
} else {
modelResult.setReturnCode("-1");
modelResult.setReturnMsg("操作数据库失败");
}
return modelResult;
}
@PostMapping("/update") | public ModelResult<City> update(@Validated @RequestBody UpdateCityRequestDto updateCityRequestDto) { |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CompanyMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Company.java
// @Data
// @NoArgsConstructor
// public class Company {
// private Long id;
//
//
// private String companyOid;
//
//
// private String name;
//
// private Long logoId;
//
// private String createdBy;
//
// private LocalDateTime createdDate;
//
// private Boolean doneRegisterLead;
//
// private String taxId;
//
// private CompanyType companyType;
//
// private LocalDateTime updateDate;
//
//
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Company;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface CompanyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table company
*
* @mbg.generated Tue Apr 11 15:11:59 CST 2017
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table company
*
* @mbg.generated Tue Apr 11 15:11:59 CST 2017
*/ | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Company.java
// @Data
// @NoArgsConstructor
// public class Company {
// private Long id;
//
//
// private String companyOid;
//
//
// private String name;
//
// private Long logoId;
//
// private String createdBy;
//
// private LocalDateTime createdDate;
//
// private Boolean doneRegisterLead;
//
// private String taxId;
//
// private CompanyType companyType;
//
// private LocalDateTime updateDate;
//
//
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CompanyMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Company;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface CompanyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table company
*
* @mbg.generated Tue Apr 11 15:11:59 CST 2017
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table company
*
* @mbg.generated Tue Apr 11 15:11:59 CST 2017
*/ | int insert(Company record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.UserAuthority;
import java.util.List; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface UserAuthorityMapper { | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.UserAuthority;
import java.util.List;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface UserAuthorityMapper { | int deleteByPrimaryKey(UserAuthority key); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CourseMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Course.java
// public class Course {
// private Long courseId;
//
// private String name;
//
// private String description;
//
// private Date startDate;
//
// private Date endDate;
//
// private Long tutorId;
//
// public Long getCourseId() {
// return courseId;
// }
//
// public void setCourseId(Long courseId) {
// this.courseId = courseId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description == null ? null : description.trim();
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
// this.startDate = startDate;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
// this.endDate = endDate;
// }
//
// public Long getTutorId() {
// return tutorId;
// }
//
// public void setTutorId(Long tutorId) {
// this.tutorId = tutorId;
// }
// }
| import com.sdcuike.practice.domain.Course; | package com.sdcuike.practice.mapper;
public interface CourseMapper {
int deleteByPrimaryKey(Long courseId);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Course.java
// public class Course {
// private Long courseId;
//
// private String name;
//
// private String description;
//
// private Date startDate;
//
// private Date endDate;
//
// private Long tutorId;
//
// public Long getCourseId() {
// return courseId;
// }
//
// public void setCourseId(Long courseId) {
// this.courseId = courseId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description == null ? null : description.trim();
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
// this.startDate = startDate;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
// this.endDate = endDate;
// }
//
// public Long getTutorId() {
// return tutorId;
// }
//
// public void setTutorId(Long tutorId) {
// this.tutorId = tutorId;
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CourseMapper.java
import com.sdcuike.practice.domain.Course;
package com.sdcuike.practice.mapper;
public interface CourseMapper {
int deleteByPrimaryKey(Long courseId);
| int insert(Course record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/ExampleController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Company.java
// @Data
// @NoArgsConstructor
// public class Company {
// private Long id;
//
//
// private String companyOid;
//
//
// private String name;
//
// private Long logoId;
//
// private String createdBy;
//
// private LocalDateTime createdDate;
//
// private Boolean doneRegisterLead;
//
// private String taxId;
//
// private CompanyType companyType;
//
// private LocalDateTime updateDate;
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CompanyMapper.java
// @UseDataSourceTest
// public interface CompanyMapper {
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int deleteByPrimaryKey(Long id);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insert(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insertSelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// Company selectByPrimaryKey(Long id);
//
// List<Company> selectAll();
//
// Page<Company> selectAllPageable(@Param("page") Pageable pageable);
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKeySelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKey(Company record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.Company;
import com.sdcuike.practice.mapper.CompanyMapper;
import com.sdcuike.spring.extend.web.util.PaginationUtil;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URISyntaxException;
import java.util.List; | package com.sdcuike.practice.controller;
@RestController
@RequestMapping(path = "/example", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class ExampleController {
@Resource | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Company.java
// @Data
// @NoArgsConstructor
// public class Company {
// private Long id;
//
//
// private String companyOid;
//
//
// private String name;
//
// private Long logoId;
//
// private String createdBy;
//
// private LocalDateTime createdDate;
//
// private Boolean doneRegisterLead;
//
// private String taxId;
//
// private CompanyType companyType;
//
// private LocalDateTime updateDate;
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CompanyMapper.java
// @UseDataSourceTest
// public interface CompanyMapper {
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int deleteByPrimaryKey(Long id);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insert(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insertSelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// Company selectByPrimaryKey(Long id);
//
// List<Company> selectAll();
//
// Page<Company> selectAllPageable(@Param("page") Pageable pageable);
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKeySelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKey(Company record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/ExampleController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.Company;
import com.sdcuike.practice.mapper.CompanyMapper;
import com.sdcuike.spring.extend.web.util.PaginationUtil;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URISyntaxException;
import java.util.List;
package com.sdcuike.practice.controller;
@RestController
@RequestMapping(path = "/example", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class ExampleController {
@Resource | private CompanyMapper companyMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/ExampleController.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Company.java
// @Data
// @NoArgsConstructor
// public class Company {
// private Long id;
//
//
// private String companyOid;
//
//
// private String name;
//
// private Long logoId;
//
// private String createdBy;
//
// private LocalDateTime createdDate;
//
// private Boolean doneRegisterLead;
//
// private String taxId;
//
// private CompanyType companyType;
//
// private LocalDateTime updateDate;
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CompanyMapper.java
// @UseDataSourceTest
// public interface CompanyMapper {
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int deleteByPrimaryKey(Long id);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insert(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insertSelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// Company selectByPrimaryKey(Long id);
//
// List<Company> selectAll();
//
// Page<Company> selectAllPageable(@Param("page") Pageable pageable);
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKeySelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKey(Company record);
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.Company;
import com.sdcuike.practice.mapper.CompanyMapper;
import com.sdcuike.spring.extend.web.util.PaginationUtil;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URISyntaxException;
import java.util.List; | package com.sdcuike.practice.controller;
@RestController
@RequestMapping(path = "/example", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class ExampleController {
@Resource
private CompanyMapper companyMapper;
@GetMapping("/")
public ModelResult<String> home() {
ModelResult<String> modelResult = new ModelResult<>();
modelResult.setData("hello world spring boot");
return modelResult;
}
@GetMapping("/all_company") | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Company.java
// @Data
// @NoArgsConstructor
// public class Company {
// private Long id;
//
//
// private String companyOid;
//
//
// private String name;
//
// private Long logoId;
//
// private String createdBy;
//
// private LocalDateTime createdDate;
//
// private Boolean doneRegisterLead;
//
// private String taxId;
//
// private CompanyType companyType;
//
// private LocalDateTime updateDate;
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/CompanyMapper.java
// @UseDataSourceTest
// public interface CompanyMapper {
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int deleteByPrimaryKey(Long id);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insert(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int insertSelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// Company selectByPrimaryKey(Long id);
//
// List<Company> selectAll();
//
// Page<Company> selectAllPageable(@Param("page") Pageable pageable);
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKeySelective(Company record);
//
// /**
// * This method was generated by MyBatis Generator.
// * This method corresponds to the database table company
// *
// * @mbg.generated Tue Apr 11 15:11:59 CST 2017
// */
// int updateByPrimaryKey(Company record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/controller/ExampleController.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.domain.Company;
import com.sdcuike.practice.mapper.CompanyMapper;
import com.sdcuike.spring.extend.web.util.PaginationUtil;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URISyntaxException;
import java.util.List;
package com.sdcuike.practice.controller;
@RestController
@RequestMapping(path = "/example", produces = MediaType.APPLICATION_JSON_VALUE)
@Slf4j
public class ExampleController {
@Resource
private CompanyMapper companyMapper;
@GetMapping("/")
public ModelResult<String> home() {
ModelResult<String> modelResult = new ModelResult<>();
modelResult.setData("hello world spring boot");
return modelResult;
}
@GetMapping("/all_company") | public List<Company> queryAllCompany() { |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/AuditorConfig.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
| import com.sdcuike.mybatis.auditor.AuditorServiceUtis;
import com.sdcuike.practice.mapper.StudentMapper;
import com.sdcuike.spring.extend.web.SpringHandlerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.UUID; | package com.sdcuike.practice.config;
/**
* Created by beaver on 2017/4/25.
*
* 注入自己的服务,利用AuditorServiceUtis.setUserId 设值。
*/
@SpringHandlerInterceptor
@Slf4j
public class AuditorConfig extends HandlerInterceptorAdapter {
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
// @UseDataSourceTest
// public interface StudentMapper {
// int deleteByPrimaryKey(Long studId);
//
// int insert(StudentWithBLOBs record);
//
// int insertSelective(StudentWithBLOBs record);
//
// StudentWithBLOBs selectByPrimaryKey(Long studId);
//
// int updateByPrimaryKeySelective(StudentWithBLOBs record);
//
// int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
//
// int updateByPrimaryKey(Student record);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/AuditorConfig.java
import com.sdcuike.mybatis.auditor.AuditorServiceUtis;
import com.sdcuike.practice.mapper.StudentMapper;
import com.sdcuike.spring.extend.web.SpringHandlerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.UUID;
package com.sdcuike.practice.config;
/**
* Created by beaver on 2017/4/25.
*
* 注入自己的服务,利用AuditorServiceUtis.setUserId 设值。
*/
@SpringHandlerInterceptor
@Slf4j
public class AuditorConfig extends HandlerInterceptorAdapter {
@Autowired | private StudentMapper studentMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
| import com.sdcuike.practice.domain.City;
import org.mapstruct.Mapper; | package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/4/14.
*/
@Mapper
public interface CityDtoMapper { | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/City.java
// @Data
// @NoArgsConstructor
// public class City extends AbstractAuditingEntity implements Serializable {
// private static final long serialVersionUID = 1L;
//
// /**
// * 城市id
// */
// private Long id;
//
// private String name;
//
// private String state;
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/CityDtoMapper.java
import com.sdcuike.practice.domain.City;
import org.mapstruct.Mapper;
package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/4/14.
*/
@Mapper
public interface CityDtoMapper { | InsertCityRequestDto cityToDto(City city); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
| import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; | package com.sdcuike.practice.config.security;
/**
* Authenticate a user from the database.
*/
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java
import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
package com.sdcuike.practice.config.security;
/**
* Authenticate a user from the database.
*/
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired | private UserMapper userMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
| import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; | package com.sdcuike.practice.config.security;
/**
* Authenticate a user from the database.
*/
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserMapper userMapper;
@Autowired | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java
import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
package com.sdcuike.practice.config.security;
/**
* Authenticate a user from the database.
*/
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserMapper userMapper;
@Autowired | private UserAuthorityMapper userAuthorityMapper; |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
| import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; | package com.sdcuike.practice.config.security;
/**
* Authenticate a user from the database.
*/
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserMapper userMapper;
@Autowired
private UserAuthorityMapper userAuthorityMapper;
@Override
@Transactional
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java
import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
package com.sdcuike.practice.config.security;
/**
* Authenticate a user from the database.
*/
@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserMapper userMapper;
@Autowired
private UserAuthorityMapper userAuthorityMapper;
@Override
@Transactional
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
| Optional<User> userFromDatabase = findOneWithAuthoritiesByLogin(login); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
| import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; | @Override
@Transactional
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
Optional<User> userFromDatabase = findOneWithAuthoritiesByLogin(login);
return userFromDatabase.map(user -> {
if (!user.getActivated()) {
throw new UserNotActivatedException("User " + login + " was not activated");
}
List<GrantedAuthority> grantedAuthorities =
user.getAuthorities()
.stream()
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
.collect(Collectors.toList());
return new RichUserDetails(user.getId(),user.getPhone(),user.getLoginName(),user.getPasswordHash(), grantedAuthorities);
}).orElseThrow(() -> new UsernameNotFoundException("User " + login + " was not found in the " +
"database"));
}
private Optional<User> findOneWithAuthoritiesByLogin(String login) {
Optional<User> user = Optional.ofNullable(userMapper.findByLoginName(login));
if (!user.isPresent()) {
return user;
}
User userDb = user.get(); | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java
import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@Override
@Transactional
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
Optional<User> userFromDatabase = findOneWithAuthoritiesByLogin(login);
return userFromDatabase.map(user -> {
if (!user.getActivated()) {
throw new UserNotActivatedException("User " + login + " was not activated");
}
List<GrantedAuthority> grantedAuthorities =
user.getAuthorities()
.stream()
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
.collect(Collectors.toList());
return new RichUserDetails(user.getId(),user.getPhone(),user.getLoginName(),user.getPasswordHash(), grantedAuthorities);
}).orElseThrow(() -> new UsernameNotFoundException("User " + login + " was not found in the " +
"database"));
}
private Optional<User> findOneWithAuthoritiesByLogin(String login) {
Optional<User> user = Optional.ofNullable(userMapper.findByLoginName(login));
if (!user.isPresent()) {
return user;
}
User userDb = user.get(); | List<UserAuthority> userAuthorities = userAuthorityMapper.findByUserId(userDb.getId()); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
| import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; | public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
Optional<User> userFromDatabase = findOneWithAuthoritiesByLogin(login);
return userFromDatabase.map(user -> {
if (!user.getActivated()) {
throw new UserNotActivatedException("User " + login + " was not activated");
}
List<GrantedAuthority> grantedAuthorities =
user.getAuthorities()
.stream()
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
.collect(Collectors.toList());
return new RichUserDetails(user.getId(),user.getPhone(),user.getLoginName(),user.getPasswordHash(), grantedAuthorities);
}).orElseThrow(() -> new UsernameNotFoundException("User " + login + " was not found in the " +
"database"));
}
private Optional<User> findOneWithAuthoritiesByLogin(String login) {
Optional<User> user = Optional.ofNullable(userMapper.findByLoginName(login));
if (!user.isPresent()) {
return user;
}
User userDb = user.get();
List<UserAuthority> userAuthorities = userAuthorityMapper.findByUserId(userDb.getId());
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Authority.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Authority {
// private String name;
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/User.java
// @Data
// @NoArgsConstructor
// public class User extends AbstractAuditingEntity {
// private Long id;
//
// private String loginName;
//
// private String phone;
//
// private String passwordHash;
//
// private String firstName;
//
// private String lastName;
//
// private String email;
//
// private String imageUrl;
//
// private Boolean activated;
//
// private String langKey;
//
// private String activationKey;
//
// private String resetKey;
//
// private Date resetTime;
//
// private Set<Authority> authorities = new HashSet<>();
//
//
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserAuthority.java
// public class UserAuthority {
// private Long userId;
//
// private String authorityName;
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getAuthorityName() {
// return authorityName;
// }
//
// public void setAuthorityName(String authorityName) {
// this.authorityName = authorityName == null ? null : authorityName.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserAuthorityMapper.java
// @UseDataSourceTest
// public interface UserAuthorityMapper {
// int deleteByPrimaryKey(UserAuthority key);
//
// int insert(UserAuthority record);
//
// int insertSelective(UserAuthority record);
//
// List<UserAuthority> findByUserId(Long userId);
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserMapper.java
// @UseDataSourceTest
// public interface UserMapper {
// int deleteByPrimaryKey(Long id);
//
// int insert(User record);
//
// int insertSelective(User record);
//
// User selectByPrimaryKey(Long id);
//
// int updateByPrimaryKeySelective(User record);
//
// int updateByPrimaryKey(User record);
// User findByLoginName(String loginName);
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/config/security/UserDetailsServiceImpl.java
import com.sdcuike.practice.domain.Authority;
import com.sdcuike.practice.domain.User;
import com.sdcuike.practice.domain.UserAuthority;
import com.sdcuike.practice.mapper.UserAuthorityMapper;
import com.sdcuike.practice.mapper.UserMapper;
import com.sdcuike.spring.security.RichUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
Optional<User> userFromDatabase = findOneWithAuthoritiesByLogin(login);
return userFromDatabase.map(user -> {
if (!user.getActivated()) {
throw new UserNotActivatedException("User " + login + " was not activated");
}
List<GrantedAuthority> grantedAuthorities =
user.getAuthorities()
.stream()
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
.collect(Collectors.toList());
return new RichUserDetails(user.getId(),user.getPhone(),user.getLoginName(),user.getPasswordHash(), grantedAuthorities);
}).orElseThrow(() -> new UsernameNotFoundException("User " + login + " was not found in the " +
"database"));
}
private Optional<User> findOneWithAuthoritiesByLogin(String login) {
Optional<User> user = Optional.ofNullable(userMapper.findByLoginName(login));
if (!user.isPresent()) {
return user;
}
User userDb = user.get();
List<UserAuthority> userAuthorities = userAuthorityMapper.findByUserId(userDb.getId());
| Set<Authority> collect = userAuthorities.stream() |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Student.java
// @Data
// @NoArgsConstructor
// public class Student {
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<Address> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Student;
import com.sdcuike.practice.domain.StudentWithBLOBs; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface StudentMapper {
int deleteByPrimaryKey(Long studId);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Student.java
// @Data
// @NoArgsConstructor
// public class Student {
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<Address> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Student;
import com.sdcuike.practice.domain.StudentWithBLOBs;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface StudentMapper {
int deleteByPrimaryKey(Long studId);
| int insert(StudentWithBLOBs record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Student.java
// @Data
// @NoArgsConstructor
// public class Student {
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<Address> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
| import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Student;
import com.sdcuike.practice.domain.StudentWithBLOBs; | package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface StudentMapper {
int deleteByPrimaryKey(Long studId);
int insert(StudentWithBLOBs record);
int insertSelective(StudentWithBLOBs record);
StudentWithBLOBs selectByPrimaryKey(Long studId);
int updateByPrimaryKeySelective(StudentWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Student.java
// @Data
// @NoArgsConstructor
// public class Student {
// private Long studId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private LocalDateTime dob;
//
// private List<Address> addresses;
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/StudentWithBLOBs.java
// public class StudentWithBLOBs extends Student {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/StudentMapper.java
import com.sdcuike.practice.config.DatasourceConfig.UseDataSourceTest;
import com.sdcuike.practice.domain.Student;
import com.sdcuike.practice.domain.StudentWithBLOBs;
package com.sdcuike.practice.mapper;
@UseDataSourceTest
public interface StudentMapper {
int deleteByPrimaryKey(Long studId);
int insert(StudentWithBLOBs record);
int insertSelective(StudentWithBLOBs record);
StudentWithBLOBs selectByPrimaryKey(Long studId);
int updateByPrimaryKeySelective(StudentWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(StudentWithBLOBs record);
| int updateByPrimaryKey(Student record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserPicMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPic.java
// public class UserPic {
// private Long id;
//
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPicWithBLOBs.java
// public class UserPicWithBLOBs extends UserPic {
// private byte[] pic;
//
// private String bio;
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
// }
| import com.sdcuike.practice.domain.UserPic;
import com.sdcuike.practice.domain.UserPicWithBLOBs; | package com.sdcuike.practice.mapper;
public interface UserPicMapper {
int deleteByPrimaryKey(Long id);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPic.java
// public class UserPic {
// private Long id;
//
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPicWithBLOBs.java
// public class UserPicWithBLOBs extends UserPic {
// private byte[] pic;
//
// private String bio;
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserPicMapper.java
import com.sdcuike.practice.domain.UserPic;
import com.sdcuike.practice.domain.UserPicWithBLOBs;
package com.sdcuike.practice.mapper;
public interface UserPicMapper {
int deleteByPrimaryKey(Long id);
| int insert(UserPicWithBLOBs record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserPicMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPic.java
// public class UserPic {
// private Long id;
//
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPicWithBLOBs.java
// public class UserPicWithBLOBs extends UserPic {
// private byte[] pic;
//
// private String bio;
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
// }
| import com.sdcuike.practice.domain.UserPic;
import com.sdcuike.practice.domain.UserPicWithBLOBs; | package com.sdcuike.practice.mapper;
public interface UserPicMapper {
int deleteByPrimaryKey(Long id);
int insert(UserPicWithBLOBs record);
int insertSelective(UserPicWithBLOBs record);
UserPicWithBLOBs selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(UserPicWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(UserPicWithBLOBs record);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPic.java
// public class UserPic {
// private Long id;
//
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/UserPicWithBLOBs.java
// public class UserPicWithBLOBs extends UserPic {
// private byte[] pic;
//
// private String bio;
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/UserPicMapper.java
import com.sdcuike.practice.domain.UserPic;
import com.sdcuike.practice.domain.UserPicWithBLOBs;
package com.sdcuike.practice.mapper;
public interface UserPicMapper {
int deleteByPrimaryKey(Long id);
int insert(UserPicWithBLOBs record);
int insertSelective(UserPicWithBLOBs record);
UserPicWithBLOBs selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(UserPicWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(UserPicWithBLOBs record);
| int updateByPrimaryKey(UserPic record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/TutorMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Tutor.java
// public class Tutor {
// private Long tutorId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private Date dob;
//
// private Long addrId;
//
// public Long getTutorId() {
// return tutorId;
// }
//
// public void setTutorId(Long tutorId) {
// this.tutorId = tutorId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email == null ? null : email.trim();
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone == null ? null : phone.trim();
// }
//
// public Date getDob() {
// return dob;
// }
//
// public void setDob(Date dob) {
// this.dob = dob;
// }
//
// public Long getAddrId() {
// return addrId;
// }
//
// public void setAddrId(Long addrId) {
// this.addrId = addrId;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/TutorWithBLOBs.java
// public class TutorWithBLOBs extends Tutor {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
| import com.sdcuike.practice.domain.Tutor;
import com.sdcuike.practice.domain.TutorWithBLOBs; | package com.sdcuike.practice.mapper;
public interface TutorMapper {
int deleteByPrimaryKey(Long tutorId);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Tutor.java
// public class Tutor {
// private Long tutorId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private Date dob;
//
// private Long addrId;
//
// public Long getTutorId() {
// return tutorId;
// }
//
// public void setTutorId(Long tutorId) {
// this.tutorId = tutorId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email == null ? null : email.trim();
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone == null ? null : phone.trim();
// }
//
// public Date getDob() {
// return dob;
// }
//
// public void setDob(Date dob) {
// this.dob = dob;
// }
//
// public Long getAddrId() {
// return addrId;
// }
//
// public void setAddrId(Long addrId) {
// this.addrId = addrId;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/TutorWithBLOBs.java
// public class TutorWithBLOBs extends Tutor {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/TutorMapper.java
import com.sdcuike.practice.domain.Tutor;
import com.sdcuike.practice.domain.TutorWithBLOBs;
package com.sdcuike.practice.mapper;
public interface TutorMapper {
int deleteByPrimaryKey(Long tutorId);
| int insert(TutorWithBLOBs record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/TutorMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Tutor.java
// public class Tutor {
// private Long tutorId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private Date dob;
//
// private Long addrId;
//
// public Long getTutorId() {
// return tutorId;
// }
//
// public void setTutorId(Long tutorId) {
// this.tutorId = tutorId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email == null ? null : email.trim();
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone == null ? null : phone.trim();
// }
//
// public Date getDob() {
// return dob;
// }
//
// public void setDob(Date dob) {
// this.dob = dob;
// }
//
// public Long getAddrId() {
// return addrId;
// }
//
// public void setAddrId(Long addrId) {
// this.addrId = addrId;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/TutorWithBLOBs.java
// public class TutorWithBLOBs extends Tutor {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
| import com.sdcuike.practice.domain.Tutor;
import com.sdcuike.practice.domain.TutorWithBLOBs; | package com.sdcuike.practice.mapper;
public interface TutorMapper {
int deleteByPrimaryKey(Long tutorId);
int insert(TutorWithBLOBs record);
int insertSelective(TutorWithBLOBs record);
TutorWithBLOBs selectByPrimaryKey(Long tutorId);
int updateByPrimaryKeySelective(TutorWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(TutorWithBLOBs record);
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Tutor.java
// public class Tutor {
// private Long tutorId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private Date dob;
//
// private Long addrId;
//
// public Long getTutorId() {
// return tutorId;
// }
//
// public void setTutorId(Long tutorId) {
// this.tutorId = tutorId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name == null ? null : name.trim();
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email == null ? null : email.trim();
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone == null ? null : phone.trim();
// }
//
// public Date getDob() {
// return dob;
// }
//
// public void setDob(Date dob) {
// this.dob = dob;
// }
//
// public Long getAddrId() {
// return addrId;
// }
//
// public void setAddrId(Long addrId) {
// this.addrId = addrId;
// }
// }
//
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/TutorWithBLOBs.java
// public class TutorWithBLOBs extends Tutor {
// private String bio;
//
// private byte[] pic;
//
// public String getBio() {
// return bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio == null ? null : bio.trim();
// }
//
// public byte[] getPic() {
// return pic;
// }
//
// public void setPic(byte[] pic) {
// this.pic = pic;
// }
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/mapper/TutorMapper.java
import com.sdcuike.practice.domain.Tutor;
import com.sdcuike.practice.domain.TutorWithBLOBs;
package com.sdcuike.practice.mapper;
public interface TutorMapper {
int deleteByPrimaryKey(Long tutorId);
int insert(TutorWithBLOBs record);
int insertSelective(TutorWithBLOBs record);
TutorWithBLOBs selectByPrimaryKey(Long tutorId);
int updateByPrimaryKeySelective(TutorWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(TutorWithBLOBs record);
| int updateByPrimaryKey(Tutor record); |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/feign/ExampleServiceFeignClient.java | // Path: spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/config/feign/OAuth2FeignAutoConfiguration.java
// @Configuration
// public class OAuth2FeignAutoConfiguration {
//
// @Bean
// public RequestInterceptor oauth2FeignRequestInterceptor(@Qualifier("practiceOAuth2RestTemplate") OAuth2RestTemplate oAuth2RestTemplate) {
// return new OAuth2FeignRequestInterceptor(oAuth2RestTemplate);
// }
// }
| import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.config.feign.OAuth2FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; | package com.sdcuike.practice.feign;
/**
* Created by beaver on 2017/5/27.<br>
* <p>
* {@link https://jmnarloch.wordpress.com/2015/10/14/spring-cloud-feign-oauth2-authentication }
*/
@FeignClient(name = "exampleService",
url = "${exampleService.ribbon.listOfServers}", | // Path: spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/config/feign/OAuth2FeignAutoConfiguration.java
// @Configuration
// public class OAuth2FeignAutoConfiguration {
//
// @Bean
// public RequestInterceptor oauth2FeignRequestInterceptor(@Qualifier("practiceOAuth2RestTemplate") OAuth2RestTemplate oAuth2RestTemplate) {
// return new OAuth2FeignRequestInterceptor(oAuth2RestTemplate);
// }
// }
// Path: spring-boot-oauth-resource-server/src/main/java/com/sdcuike/practice/feign/ExampleServiceFeignClient.java
import com.doctor.beaver.domain.result.ModelResult;
import com.sdcuike.practice.config.feign.OAuth2FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
package com.sdcuike.practice.feign;
/**
* Created by beaver on 2017/5/27.<br>
* <p>
* {@link https://jmnarloch.wordpress.com/2015/10/14/spring-cloud-feign-oauth2-authentication }
*/
@FeignClient(name = "exampleService",
url = "${exampleService.ribbon.listOfServers}", | configuration = {OAuth2FeignAutoConfiguration.class}) |
sdcuike/spring-boot-oauth2-demo | spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/AddressDtoMapper.java | // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Address.java
// @Data
// @NoArgsConstructor
// public class Address {
// private Long addrId;
//
// private String street;
//
// private String city;
//
// private String state;
//
// private String zip;
//
// private String country;
//
// public static void main(String[] args) throws InterruptedException {
// CompletableFuture.supplyAsync(()-> {
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// System.out.println(Thread.currentThread().getName());
// return 8;
// }).thenApplyAsync( t -> {
// System.out.println(Thread.currentThread().getName());
// return t*t;
// })
// .thenAccept(t ->{
// System.out.println(Thread.currentThread().getName());
// System.out.println(t);
// });
//
// System.out.println("main");
// TimeUnit.HOURS.sleep(1L);
// }
//
//
// }
| import com.sdcuike.practice.domain.Address;
import org.mapstruct.Mapper; | package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/5/2.
*/
@Mapper
public interface AddressDtoMapper {
| // Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/Address.java
// @Data
// @NoArgsConstructor
// public class Address {
// private Long addrId;
//
// private String street;
//
// private String city;
//
// private String state;
//
// private String zip;
//
// private String country;
//
// public static void main(String[] args) throws InterruptedException {
// CompletableFuture.supplyAsync(()-> {
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// System.out.println(Thread.currentThread().getName());
// return 8;
// }).thenApplyAsync( t -> {
// System.out.println(Thread.currentThread().getName());
// return t*t;
// })
// .thenAccept(t ->{
// System.out.println(Thread.currentThread().getName());
// System.out.println(t);
// });
//
// System.out.println("main");
// TimeUnit.HOURS.sleep(1L);
// }
//
//
// }
// Path: spring-boot-oauth-authorization-server/src/main/java/com/sdcuike/practice/domain/dto/AddressDtoMapper.java
import com.sdcuike.practice.domain.Address;
import org.mapstruct.Mapper;
package com.sdcuike.practice.domain.dto;
/**
* Created by beaver on 2017/5/2.
*/
@Mapper
public interface AddressDtoMapper {
| AddressDto address2Dto(Address address); |
lgvalle/Beautiful-Photos | app/src/main/java/com/lgvalle/beaufitulphotos/interfaces/BeautifulPhotosPresenter.java | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/Feature.java
// public enum Feature {
// Popular("popular", R.string.feature_popular),
// HighestRated("highest_rated", R.string.feature_highest_rated);
//
// private final String param;
// private final int title;
//
// Feature(String param, int title) {
// this.param = param;
// this.title = title;
// }
//
// public String getParam() {
// return param;
// }
//
// public int getTitle() {
// return title;
// }
// }
| import android.content.Context;
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.Feature; | package com.lgvalle.beaufitulphotos.interfaces;
/**
* Created by lgvalle on 21/07/14.
* <p/>
* Interface for main activity presenter.
* This is just a simple example to illustrate how it's works
*/
public interface BeautifulPhotosPresenter {
/**
* Request photos from service and post results into events bus
*/
void needPhotos();
/**
* Request details for photo and post results into events bus
* @param photoModel Photo from which details are needed
*/
void needPhotoDetails(PhotoModel photoModel);
/**
* Switch service feature resetting previous data and requesting new photos
* @param feature New feature to switch to
*/ | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/Feature.java
// public enum Feature {
// Popular("popular", R.string.feature_popular),
// HighestRated("highest_rated", R.string.feature_highest_rated);
//
// private final String param;
// private final int title;
//
// Feature(String param, int title) {
// this.param = param;
// this.title = title;
// }
//
// public String getParam() {
// return param;
// }
//
// public int getTitle() {
// return title;
// }
// }
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/interfaces/BeautifulPhotosPresenter.java
import android.content.Context;
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.Feature;
package com.lgvalle.beaufitulphotos.interfaces;
/**
* Created by lgvalle on 21/07/14.
* <p/>
* Interface for main activity presenter.
* This is just a simple example to illustrate how it's works
*/
public interface BeautifulPhotosPresenter {
/**
* Request photos from service and post results into events bus
*/
void needPhotos();
/**
* Request details for photo and post results into events bus
* @param photoModel Photo from which details are needed
*/
void needPhotoDetails(PhotoModel photoModel);
/**
* Switch service feature resetting previous data and requesting new photos
* @param feature New feature to switch to
*/ | void switchFeature(Feature feature); |
lgvalle/Beautiful-Photos | app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxService.java | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/Favorites.java
// public class Favorites implements Serializable{
// @JsonProperty("total_items")
// int totalItems;
//
// public int getTotalItems() {
// return totalItems;
// }
//
// public void setTotalItems(int totalItems) {
// this.totalItems = totalItems;
// }
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/PhotosResponse.java
// public class PhotosResponse implements Serializable{
//
// @JsonProperty("current_page")
// private Integer currentPage;
// @JsonProperty("total_pages")
// private Integer totalPages;
// @JsonProperty("photos")
// private List<Photo500px> photos;
//
// public PhotosResponse() {
// currentPage = 0;
// totalPages = 0;
// photos = new ArrayList<Photo500px>();
// }
//
// public Integer getCurrentPage() {
// return currentPage;
// }
//
// public void setCurrentPage(Integer currentPage) {
// this.currentPage = currentPage;
// }
//
// public List<Photo500px> getPhotos() {
// return photos;
// }
//
// public void setPhotos(List<Photo500px> photos) {
// this.photos = photos;
// }
//
// public Integer getTotalPages() {
// return totalPages;
// }
//
// public void setTotalPages(Integer totalPages) {
// this.totalPages = totalPages;
// }
// }
| import com.lgvalle.beaufitulphotos.fivehundredpxs.model.Favorites;
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.PhotosResponse;
import ly.apps.android.rest.cache.CachePolicy;
import ly.apps.android.rest.client.Callback;
import ly.apps.android.rest.client.annotations.*; | package com.lgvalle.beaufitulphotos.fivehundredpxs;
/**
* Created by lgvalle on 22/07/14.
* <p/>
* Retrofit interface describing a 500px APi endpoint
*/
@RestService
public interface Api500pxService {
/* Consumer key is app specific */
public static final String CONSUMER_KEY_VALUE = "B2VtIGTPFrbg1YXUVujHhKIo5I9lVjBxgPIFk7A4";
public final static int FIRST_PAGE = 1;
public final static int SIZE_SMALL = 3;
public final static int SIZE_BIG = 4;
public final static int FIVE_MINUTES = 5 * 60 * 1000;
/**
* Query for /photos and specify a image size and page
* Documentation: https://github.com/500px/api-documentation/blob/master/endpoints/photo/GET_photos.md
* <p/>
* For example, this creates a query like: https://api.500px.com/v1/photos?feature=popular&image_size[]=2&image_size[]=4&page=1
*
* @param feature For example 'popular'
* @param sizeSmall Number between 1 and 4
* @param sizeLarge Number between 1 and 4
* @param page Page to fetch, starts in 1
* @param callback Callback to access response
*/
@GET("/photos")
@Cached(policy = CachePolicy.ENABLED, timeToLive = FIVE_MINUTES)
void getPhotos(@QueryParam("consumer_key") String key,
@QueryParam("image_size[]") int sizeSmall,
@QueryParam("image_size[]") int sizeLarge,
@QueryParam("feature") String feature,
@QueryParam("page") int page, | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/Favorites.java
// public class Favorites implements Serializable{
// @JsonProperty("total_items")
// int totalItems;
//
// public int getTotalItems() {
// return totalItems;
// }
//
// public void setTotalItems(int totalItems) {
// this.totalItems = totalItems;
// }
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/PhotosResponse.java
// public class PhotosResponse implements Serializable{
//
// @JsonProperty("current_page")
// private Integer currentPage;
// @JsonProperty("total_pages")
// private Integer totalPages;
// @JsonProperty("photos")
// private List<Photo500px> photos;
//
// public PhotosResponse() {
// currentPage = 0;
// totalPages = 0;
// photos = new ArrayList<Photo500px>();
// }
//
// public Integer getCurrentPage() {
// return currentPage;
// }
//
// public void setCurrentPage(Integer currentPage) {
// this.currentPage = currentPage;
// }
//
// public List<Photo500px> getPhotos() {
// return photos;
// }
//
// public void setPhotos(List<Photo500px> photos) {
// this.photos = photos;
// }
//
// public Integer getTotalPages() {
// return totalPages;
// }
//
// public void setTotalPages(Integer totalPages) {
// this.totalPages = totalPages;
// }
// }
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxService.java
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.Favorites;
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.PhotosResponse;
import ly.apps.android.rest.cache.CachePolicy;
import ly.apps.android.rest.client.Callback;
import ly.apps.android.rest.client.annotations.*;
package com.lgvalle.beaufitulphotos.fivehundredpxs;
/**
* Created by lgvalle on 22/07/14.
* <p/>
* Retrofit interface describing a 500px APi endpoint
*/
@RestService
public interface Api500pxService {
/* Consumer key is app specific */
public static final String CONSUMER_KEY_VALUE = "B2VtIGTPFrbg1YXUVujHhKIo5I9lVjBxgPIFk7A4";
public final static int FIRST_PAGE = 1;
public final static int SIZE_SMALL = 3;
public final static int SIZE_BIG = 4;
public final static int FIVE_MINUTES = 5 * 60 * 1000;
/**
* Query for /photos and specify a image size and page
* Documentation: https://github.com/500px/api-documentation/blob/master/endpoints/photo/GET_photos.md
* <p/>
* For example, this creates a query like: https://api.500px.com/v1/photos?feature=popular&image_size[]=2&image_size[]=4&page=1
*
* @param feature For example 'popular'
* @param sizeSmall Number between 1 and 4
* @param sizeLarge Number between 1 and 4
* @param page Page to fetch, starts in 1
* @param callback Callback to access response
*/
@GET("/photos")
@Cached(policy = CachePolicy.ENABLED, timeToLive = FIVE_MINUTES)
void getPhotos(@QueryParam("consumer_key") String key,
@QueryParam("image_size[]") int sizeSmall,
@QueryParam("image_size[]") int sizeLarge,
@QueryParam("feature") String feature,
@QueryParam("page") int page, | Callback<PhotosResponse> callback); |
lgvalle/Beautiful-Photos | app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxService.java | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/Favorites.java
// public class Favorites implements Serializable{
// @JsonProperty("total_items")
// int totalItems;
//
// public int getTotalItems() {
// return totalItems;
// }
//
// public void setTotalItems(int totalItems) {
// this.totalItems = totalItems;
// }
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/PhotosResponse.java
// public class PhotosResponse implements Serializable{
//
// @JsonProperty("current_page")
// private Integer currentPage;
// @JsonProperty("total_pages")
// private Integer totalPages;
// @JsonProperty("photos")
// private List<Photo500px> photos;
//
// public PhotosResponse() {
// currentPage = 0;
// totalPages = 0;
// photos = new ArrayList<Photo500px>();
// }
//
// public Integer getCurrentPage() {
// return currentPage;
// }
//
// public void setCurrentPage(Integer currentPage) {
// this.currentPage = currentPage;
// }
//
// public List<Photo500px> getPhotos() {
// return photos;
// }
//
// public void setPhotos(List<Photo500px> photos) {
// this.photos = photos;
// }
//
// public Integer getTotalPages() {
// return totalPages;
// }
//
// public void setTotalPages(Integer totalPages) {
// this.totalPages = totalPages;
// }
// }
| import com.lgvalle.beaufitulphotos.fivehundredpxs.model.Favorites;
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.PhotosResponse;
import ly.apps.android.rest.cache.CachePolicy;
import ly.apps.android.rest.client.Callback;
import ly.apps.android.rest.client.annotations.*; | package com.lgvalle.beaufitulphotos.fivehundredpxs;
/**
* Created by lgvalle on 22/07/14.
* <p/>
* Retrofit interface describing a 500px APi endpoint
*/
@RestService
public interface Api500pxService {
/* Consumer key is app specific */
public static final String CONSUMER_KEY_VALUE = "B2VtIGTPFrbg1YXUVujHhKIo5I9lVjBxgPIFk7A4";
public final static int FIRST_PAGE = 1;
public final static int SIZE_SMALL = 3;
public final static int SIZE_BIG = 4;
public final static int FIVE_MINUTES = 5 * 60 * 1000;
/**
* Query for /photos and specify a image size and page
* Documentation: https://github.com/500px/api-documentation/blob/master/endpoints/photo/GET_photos.md
* <p/>
* For example, this creates a query like: https://api.500px.com/v1/photos?feature=popular&image_size[]=2&image_size[]=4&page=1
*
* @param feature For example 'popular'
* @param sizeSmall Number between 1 and 4
* @param sizeLarge Number between 1 and 4
* @param page Page to fetch, starts in 1
* @param callback Callback to access response
*/
@GET("/photos")
@Cached(policy = CachePolicy.ENABLED, timeToLive = FIVE_MINUTES)
void getPhotos(@QueryParam("consumer_key") String key,
@QueryParam("image_size[]") int sizeSmall,
@QueryParam("image_size[]") int sizeLarge,
@QueryParam("feature") String feature,
@QueryParam("page") int page,
Callback<PhotosResponse> callback);
/**
* Returns all users that had favorite a photo.
*
* @param id Photo ID
* @param callback Object containing number of favorites for a photo
*/
@GET("/photos/{id}/favorites")
@Cached(policy = CachePolicy.ENABLED, timeToLive = FIVE_MINUTES)
void getFavorites(@QueryParam("consumer_key") String key,
@Path("id") Integer id, | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/Favorites.java
// public class Favorites implements Serializable{
// @JsonProperty("total_items")
// int totalItems;
//
// public int getTotalItems() {
// return totalItems;
// }
//
// public void setTotalItems(int totalItems) {
// this.totalItems = totalItems;
// }
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/model/PhotosResponse.java
// public class PhotosResponse implements Serializable{
//
// @JsonProperty("current_page")
// private Integer currentPage;
// @JsonProperty("total_pages")
// private Integer totalPages;
// @JsonProperty("photos")
// private List<Photo500px> photos;
//
// public PhotosResponse() {
// currentPage = 0;
// totalPages = 0;
// photos = new ArrayList<Photo500px>();
// }
//
// public Integer getCurrentPage() {
// return currentPage;
// }
//
// public void setCurrentPage(Integer currentPage) {
// this.currentPage = currentPage;
// }
//
// public List<Photo500px> getPhotos() {
// return photos;
// }
//
// public void setPhotos(List<Photo500px> photos) {
// this.photos = photos;
// }
//
// public Integer getTotalPages() {
// return totalPages;
// }
//
// public void setTotalPages(Integer totalPages) {
// this.totalPages = totalPages;
// }
// }
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxService.java
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.Favorites;
import com.lgvalle.beaufitulphotos.fivehundredpxs.model.PhotosResponse;
import ly.apps.android.rest.cache.CachePolicy;
import ly.apps.android.rest.client.Callback;
import ly.apps.android.rest.client.annotations.*;
package com.lgvalle.beaufitulphotos.fivehundredpxs;
/**
* Created by lgvalle on 22/07/14.
* <p/>
* Retrofit interface describing a 500px APi endpoint
*/
@RestService
public interface Api500pxService {
/* Consumer key is app specific */
public static final String CONSUMER_KEY_VALUE = "B2VtIGTPFrbg1YXUVujHhKIo5I9lVjBxgPIFk7A4";
public final static int FIRST_PAGE = 1;
public final static int SIZE_SMALL = 3;
public final static int SIZE_BIG = 4;
public final static int FIVE_MINUTES = 5 * 60 * 1000;
/**
* Query for /photos and specify a image size and page
* Documentation: https://github.com/500px/api-documentation/blob/master/endpoints/photo/GET_photos.md
* <p/>
* For example, this creates a query like: https://api.500px.com/v1/photos?feature=popular&image_size[]=2&image_size[]=4&page=1
*
* @param feature For example 'popular'
* @param sizeSmall Number between 1 and 4
* @param sizeLarge Number between 1 and 4
* @param page Page to fetch, starts in 1
* @param callback Callback to access response
*/
@GET("/photos")
@Cached(policy = CachePolicy.ENABLED, timeToLive = FIVE_MINUTES)
void getPhotos(@QueryParam("consumer_key") String key,
@QueryParam("image_size[]") int sizeSmall,
@QueryParam("image_size[]") int sizeLarge,
@QueryParam("feature") String feature,
@QueryParam("page") int page,
Callback<PhotosResponse> callback);
/**
* Returns all users that had favorite a photo.
*
* @param id Photo ID
* @param callback Object containing number of favorites for a photo
*/
@GET("/photos/{id}/favorites")
@Cached(policy = CachePolicy.ENABLED, timeToLive = FIVE_MINUTES)
void getFavorites(@QueryParam("consumer_key") String key,
@Path("id") Integer id, | Callback<Favorites> callback); |
lgvalle/Beautiful-Photos | app/src/main/java/com/lgvalle/beaufitulphotos/gallery/GalleryItemRenderer.java | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/interfaces/PhotoModel.java
// public interface PhotoModel extends Parcelable {
// Integer getId();
// String getSmallUrl();
// String getLargeUrl();
// String getTitle();
// String getAuthorName();
// Integer getFavorites();
// void setFavorites(Integer favorites);
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/PicassoHelper.java
// public class PicassoHelper {
// /**
// * Wrap Picasso. Load url into target. Default callback shows error if something wrong happen.
// *
// * @param url Photo url
// * @param target ImageView where photo is going to be loaded
// */
// public static void load(final Context ctx, String url, ImageView target) {
// load(ctx, url, target, new Callback() {
// @Override
// public void onError() {
// Toast.makeText(ctx, ctx.getString(R.string.service_error), Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public void onSuccess() {
// /* Photo loaded. Nothing else to do */
// }
// });
// }
//
// /**
// * Wrap Picasso. Load url into target and execute param callback
// *
// * @param url Photo url
// * @param target ImageView where photo is going to be loaded
// */
// public static void load(Context ctx, String url, ImageView target, Callback callback) {
// Picasso.with(ctx).load(url).into(target, callback);
// }
//
// /**
// * Wrap Picasso. Load url into target, apply blur transformation and execute param callback
// *
// * @param url Photo url
// * @param target ImageView where photo is going to be loaded
// * @param callback Callback executed after image is loaded
// */
// public static void loadWithBlur(Context ctx, String url, ImageView target, Callback callback) {
// // After loading, execute parameter callback
// Picasso.with(ctx).load(url).transform(new BlurTransformation(ctx)).into(target, callback);
// }
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/Renderer.java
// public abstract class Renderer<T> {
// protected View rootView;
// protected T content;
//
// /**
// * Need public empty constructor to build empty renderer
// */
// public Renderer() {}
//
// /**
// * Default constructor
// */
// protected Renderer(T content) {
// this.content = content;
// }
//
// /**
// * This method is called by RendererAdapter.
// * <p/>
// * Child classes need to implement this method to bind view with model and provide a view object for them.
// *
// * @return A view representing <b>this.content</b>
// */
// public abstract View render(Context ctx);
//
// /**
// * Child classes need to implement this method to provide a concrete renderer for each model object
// *
// * @param content Model object for which concrete renderer is providing a view
// */
// protected abstract <T> Renderer create(T content, LayoutInflater inflater, ViewGroup parent);
//
// /**
// * Create or recycle a Renderer
// */
// public Renderer build(T content, LayoutInflater inflater, ViewGroup parent, View convertView) {
// Renderer r;
// if (convertView == null) {
// r = create(content, inflater, parent);
// } else {
// r = (Renderer) convertView.getTag();
// r.onRecycle(content);
// }
//
// return r;
// }
//
// /**
// * When recycling a renderer, you only need to set a new content.
// */
// protected void onRecycle(T content) {
// this.content = content;
// }
//
// /**
// * @return Model object of this renderer
// */
// protected T getContent() {
// return this.content;
// }
//
//
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import com.facebook.rebound.*;
import com.lgvalle.beaufitulphotos.R;
import com.lgvalle.beaufitulphotos.interfaces.PhotoModel;
import com.lgvalle.beaufitulphotos.utils.PicassoHelper;
import com.lgvalle.beaufitulphotos.utils.Renderer; | package com.lgvalle.beaufitulphotos.gallery;
/**
* Created by lgvalle on 21/07/14.
* <p/>
* Concrete renderer for photomodel object.
* <p/>
* This class binds a concrete view with a concrete object.
*/
public class GalleryItemRenderer extends Renderer<PhotoModel> {
private static final SpringConfig SPRING_CONFIG = SpringConfig.fromOrigamiTensionAndFriction(10, 10);
private final Spring mSpring = SpringSystem.create().createSpring().setSpringConfig(SPRING_CONFIG).addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// Just tell the UI to update based on the springs current state.
animate();
}
});
/* Views */
@InjectView(R.id.photo)
ImageView ivPhoto;
@InjectView(R.id.photo_title)
TextView tvPhotoTitle;
public GalleryItemRenderer() {
super();
}
private GalleryItemRenderer(PhotoModel content, LayoutInflater inflater, ViewGroup parent) {
super(content);
this.rootView = inflater.inflate(R.layout.row_photo, parent, false);
this.rootView.setTag(this);
ButterKnife.inject(this, rootView);
}
/**
* Generate a view for this renderer content.
*
* @param ctx Context
* @return A view representing current content
*/
@Override
public View render(Context ctx) {
// Load photo | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/interfaces/PhotoModel.java
// public interface PhotoModel extends Parcelable {
// Integer getId();
// String getSmallUrl();
// String getLargeUrl();
// String getTitle();
// String getAuthorName();
// Integer getFavorites();
// void setFavorites(Integer favorites);
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/PicassoHelper.java
// public class PicassoHelper {
// /**
// * Wrap Picasso. Load url into target. Default callback shows error if something wrong happen.
// *
// * @param url Photo url
// * @param target ImageView where photo is going to be loaded
// */
// public static void load(final Context ctx, String url, ImageView target) {
// load(ctx, url, target, new Callback() {
// @Override
// public void onError() {
// Toast.makeText(ctx, ctx.getString(R.string.service_error), Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public void onSuccess() {
// /* Photo loaded. Nothing else to do */
// }
// });
// }
//
// /**
// * Wrap Picasso. Load url into target and execute param callback
// *
// * @param url Photo url
// * @param target ImageView where photo is going to be loaded
// */
// public static void load(Context ctx, String url, ImageView target, Callback callback) {
// Picasso.with(ctx).load(url).into(target, callback);
// }
//
// /**
// * Wrap Picasso. Load url into target, apply blur transformation and execute param callback
// *
// * @param url Photo url
// * @param target ImageView where photo is going to be loaded
// * @param callback Callback executed after image is loaded
// */
// public static void loadWithBlur(Context ctx, String url, ImageView target, Callback callback) {
// // After loading, execute parameter callback
// Picasso.with(ctx).load(url).transform(new BlurTransformation(ctx)).into(target, callback);
// }
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/Renderer.java
// public abstract class Renderer<T> {
// protected View rootView;
// protected T content;
//
// /**
// * Need public empty constructor to build empty renderer
// */
// public Renderer() {}
//
// /**
// * Default constructor
// */
// protected Renderer(T content) {
// this.content = content;
// }
//
// /**
// * This method is called by RendererAdapter.
// * <p/>
// * Child classes need to implement this method to bind view with model and provide a view object for them.
// *
// * @return A view representing <b>this.content</b>
// */
// public abstract View render(Context ctx);
//
// /**
// * Child classes need to implement this method to provide a concrete renderer for each model object
// *
// * @param content Model object for which concrete renderer is providing a view
// */
// protected abstract <T> Renderer create(T content, LayoutInflater inflater, ViewGroup parent);
//
// /**
// * Create or recycle a Renderer
// */
// public Renderer build(T content, LayoutInflater inflater, ViewGroup parent, View convertView) {
// Renderer r;
// if (convertView == null) {
// r = create(content, inflater, parent);
// } else {
// r = (Renderer) convertView.getTag();
// r.onRecycle(content);
// }
//
// return r;
// }
//
// /**
// * When recycling a renderer, you only need to set a new content.
// */
// protected void onRecycle(T content) {
// this.content = content;
// }
//
// /**
// * @return Model object of this renderer
// */
// protected T getContent() {
// return this.content;
// }
//
//
// }
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/gallery/GalleryItemRenderer.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import com.facebook.rebound.*;
import com.lgvalle.beaufitulphotos.R;
import com.lgvalle.beaufitulphotos.interfaces.PhotoModel;
import com.lgvalle.beaufitulphotos.utils.PicassoHelper;
import com.lgvalle.beaufitulphotos.utils.Renderer;
package com.lgvalle.beaufitulphotos.gallery;
/**
* Created by lgvalle on 21/07/14.
* <p/>
* Concrete renderer for photomodel object.
* <p/>
* This class binds a concrete view with a concrete object.
*/
public class GalleryItemRenderer extends Renderer<PhotoModel> {
private static final SpringConfig SPRING_CONFIG = SpringConfig.fromOrigamiTensionAndFriction(10, 10);
private final Spring mSpring = SpringSystem.create().createSpring().setSpringConfig(SPRING_CONFIG).addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// Just tell the UI to update based on the springs current state.
animate();
}
});
/* Views */
@InjectView(R.id.photo)
ImageView ivPhoto;
@InjectView(R.id.photo_title)
TextView tvPhotoTitle;
public GalleryItemRenderer() {
super();
}
private GalleryItemRenderer(PhotoModel content, LayoutInflater inflater, ViewGroup parent) {
super(content);
this.rootView = inflater.inflate(R.layout.row_photo, parent, false);
this.rootView.setTag(this);
ButterKnife.inject(this, rootView);
}
/**
* Generate a view for this renderer content.
*
* @param ctx Context
* @return A view representing current content
*/
@Override
public View render(Context ctx) {
// Load photo | PicassoHelper.load(ctx, getContent().getSmallUrl(), ivPhoto); |
lgvalle/Beautiful-Photos | app/src/main/java/com/lgvalle/beaufitulphotos/BeautifulPhotosApplication.java | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxModule.java
// public class Api500pxModule {
// private static final String END_POINT = "https://api.500px.com/v1";
// private static Api500pxService service;
//
// public static void init(Context ctx) {
// RestClient client = RestClientFactory.defaultClient(ctx);
// service = RestServiceFactory.getService(END_POINT, Api500pxService.class, client);
// }
//
// /**
// * Hide constructor
// */
// private Api500pxModule() {}
//
// /**
// * Expose rest client
// */
// public static Api500pxService getService() {
// return service;
// }
//
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/TypefaceUtil.java
// public class TypefaceUtil {
//
// /**
// * Using reflection to override default typeface
// * NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
// *
// * @param context to work with assets
// * @param defaultFontNameToOverride for example "monospace"
// * @param customFontFileNameInAssets file name of the font from assets
// */
// public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
// try {
// final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);
//
// final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
// defaultFontTypefaceField.setAccessible(true);
// defaultFontTypefaceField.set(null, customFontTypeface);
// } catch (Exception e) {
// Log.e("TypefaceUtil", "Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride);
// }
// }
// }
| import android.app.Application;
import com.lgvalle.beaufitulphotos.fivehundredpxs.Api500pxModule;
import com.lgvalle.beaufitulphotos.utils.TypefaceUtil; | package com.lgvalle.beaufitulphotos;
/**
* Created by lgvalle on 21/07/14.
*/
public class BeautifulPhotosApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Init service module | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxModule.java
// public class Api500pxModule {
// private static final String END_POINT = "https://api.500px.com/v1";
// private static Api500pxService service;
//
// public static void init(Context ctx) {
// RestClient client = RestClientFactory.defaultClient(ctx);
// service = RestServiceFactory.getService(END_POINT, Api500pxService.class, client);
// }
//
// /**
// * Hide constructor
// */
// private Api500pxModule() {}
//
// /**
// * Expose rest client
// */
// public static Api500pxService getService() {
// return service;
// }
//
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/TypefaceUtil.java
// public class TypefaceUtil {
//
// /**
// * Using reflection to override default typeface
// * NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
// *
// * @param context to work with assets
// * @param defaultFontNameToOverride for example "monospace"
// * @param customFontFileNameInAssets file name of the font from assets
// */
// public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
// try {
// final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);
//
// final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
// defaultFontTypefaceField.setAccessible(true);
// defaultFontTypefaceField.set(null, customFontTypeface);
// } catch (Exception e) {
// Log.e("TypefaceUtil", "Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride);
// }
// }
// }
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/BeautifulPhotosApplication.java
import android.app.Application;
import com.lgvalle.beaufitulphotos.fivehundredpxs.Api500pxModule;
import com.lgvalle.beaufitulphotos.utils.TypefaceUtil;
package com.lgvalle.beaufitulphotos;
/**
* Created by lgvalle on 21/07/14.
*/
public class BeautifulPhotosApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Init service module | Api500pxModule.init(this); |
lgvalle/Beautiful-Photos | app/src/main/java/com/lgvalle/beaufitulphotos/BeautifulPhotosApplication.java | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxModule.java
// public class Api500pxModule {
// private static final String END_POINT = "https://api.500px.com/v1";
// private static Api500pxService service;
//
// public static void init(Context ctx) {
// RestClient client = RestClientFactory.defaultClient(ctx);
// service = RestServiceFactory.getService(END_POINT, Api500pxService.class, client);
// }
//
// /**
// * Hide constructor
// */
// private Api500pxModule() {}
//
// /**
// * Expose rest client
// */
// public static Api500pxService getService() {
// return service;
// }
//
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/TypefaceUtil.java
// public class TypefaceUtil {
//
// /**
// * Using reflection to override default typeface
// * NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
// *
// * @param context to work with assets
// * @param defaultFontNameToOverride for example "monospace"
// * @param customFontFileNameInAssets file name of the font from assets
// */
// public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
// try {
// final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);
//
// final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
// defaultFontTypefaceField.setAccessible(true);
// defaultFontTypefaceField.set(null, customFontTypeface);
// } catch (Exception e) {
// Log.e("TypefaceUtil", "Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride);
// }
// }
// }
| import android.app.Application;
import com.lgvalle.beaufitulphotos.fivehundredpxs.Api500pxModule;
import com.lgvalle.beaufitulphotos.utils.TypefaceUtil; | package com.lgvalle.beaufitulphotos;
/**
* Created by lgvalle on 21/07/14.
*/
public class BeautifulPhotosApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Init service module
Api500pxModule.init(this);
// Replace font typeface in all application | // Path: app/src/main/java/com/lgvalle/beaufitulphotos/fivehundredpxs/Api500pxModule.java
// public class Api500pxModule {
// private static final String END_POINT = "https://api.500px.com/v1";
// private static Api500pxService service;
//
// public static void init(Context ctx) {
// RestClient client = RestClientFactory.defaultClient(ctx);
// service = RestServiceFactory.getService(END_POINT, Api500pxService.class, client);
// }
//
// /**
// * Hide constructor
// */
// private Api500pxModule() {}
//
// /**
// * Expose rest client
// */
// public static Api500pxService getService() {
// return service;
// }
//
// }
//
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/utils/TypefaceUtil.java
// public class TypefaceUtil {
//
// /**
// * Using reflection to override default typeface
// * NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
// *
// * @param context to work with assets
// * @param defaultFontNameToOverride for example "monospace"
// * @param customFontFileNameInAssets file name of the font from assets
// */
// public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
// try {
// final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);
//
// final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
// defaultFontTypefaceField.setAccessible(true);
// defaultFontTypefaceField.set(null, customFontTypeface);
// } catch (Exception e) {
// Log.e("TypefaceUtil", "Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride);
// }
// }
// }
// Path: app/src/main/java/com/lgvalle/beaufitulphotos/BeautifulPhotosApplication.java
import android.app.Application;
import com.lgvalle.beaufitulphotos.fivehundredpxs.Api500pxModule;
import com.lgvalle.beaufitulphotos.utils.TypefaceUtil;
package com.lgvalle.beaufitulphotos;
/**
* Created by lgvalle on 21/07/14.
*/
public class BeautifulPhotosApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Init service module
Api500pxModule.init(this);
// Replace font typeface in all application | TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/RobotoCondensed-Regular.ttf"); |
jingle1267/android-utils | util/src/main/java/com/ihongqiqu/util/RegUtils.java | // Path: util/src/main/java/com/ihongqiqu/util/StringUtils.java
// public static boolean isEmpty(CharSequence str) {
// return TextUtils.isEmpty(str);
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.ihongqiqu.util.StringUtils.isEmpty; | /**
* 只含字母
*
* @param data 可能只包含字母的字符串
* @return 是否只包含字母
*/
public static boolean isLetter(String data) {
String expr = "^[A-Za-z]+$";
return data.matches(expr);
}
/**
* 只是中文
*
* @param data 可能是中文的字符串
* @return 是否只是中文
*/
public static boolean isChinese(String data) {
String expr = "^[\u0391-\uFFE5]+$";
return data.matches(expr);
}
/**
* 包含中文
*
* @param data 可能包含中文的字符串
* @return 是否包含中文
*/
public static boolean isContainChinese(String data) {
String chinese = "[\u0391-\uFFE5]"; | // Path: util/src/main/java/com/ihongqiqu/util/StringUtils.java
// public static boolean isEmpty(CharSequence str) {
// return TextUtils.isEmpty(str);
// }
// Path: util/src/main/java/com/ihongqiqu/util/RegUtils.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.ihongqiqu.util.StringUtils.isEmpty;
/**
* 只含字母
*
* @param data 可能只包含字母的字符串
* @return 是否只包含字母
*/
public static boolean isLetter(String data) {
String expr = "^[A-Za-z]+$";
return data.matches(expr);
}
/**
* 只是中文
*
* @param data 可能是中文的字符串
* @return 是否只是中文
*/
public static boolean isChinese(String data) {
String expr = "^[\u0391-\uFFE5]+$";
return data.matches(expr);
}
/**
* 包含中文
*
* @param data 可能包含中文的字符串
* @return 是否包含中文
*/
public static boolean isContainChinese(String data) {
String chinese = "[\u0391-\uFFE5]"; | if (isEmpty(data)) { |
jingle1267/android-utils | util/src/main/java/com/ihongqiqu/util/PackageUtils.java | // Path: util/src/main/java/com/ihongqiqu/util/ShellUtils.java
// public static class CommandResult {
//
// /**
// * result of command *
// */
// public int result;
// /**
// * success message of command result *
// */
// public String successMsg;
// /**
// * error message of command result *
// */
// public String errorMsg;
//
// public CommandResult(int result) {
// this.result = result;
// }
//
// public CommandResult(int result, String successMsg, String errorMsg) {
// this.result = result;
// this.successMsg = successMsg;
// this.errorMsg = errorMsg;
// }
// }
| import com.ihongqiqu.util.ShellUtils.CommandResult;
import java.io.File;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log; | * app.</li>
* </ul>
*
* @param context
* @param filePath file path of package
* @param pmParams pm install params
* @return {@link PackageUtils#INSTALL_SUCCEEDED} means install success,
* other means failed. details see {@link PackageUtils}
* .INSTALL_FAILED_*. same to {@link PackageManager}.INSTALL_*
*/
public static int installSilent(Context context, String filePath,
String pmParams) {
if (filePath == null || filePath.length() == 0) {
return INSTALL_FAILED_INVALID_URI;
}
File file = new File(filePath);
if (file.length() <= 0 || !file.exists() || !file.isFile()) {
return INSTALL_FAILED_INVALID_URI;
}
/**
* if context is system app, don't need root permission, but should add
* <uses-permission android:name="android.permission.INSTALL_PACKAGES"
* /> in mainfest
**/
StringBuilder command = new StringBuilder()
.append("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm install ")
.append(pmParams == null ? "" : pmParams).append(" ")
.append(filePath.replace(" ", "\\ ")); | // Path: util/src/main/java/com/ihongqiqu/util/ShellUtils.java
// public static class CommandResult {
//
// /**
// * result of command *
// */
// public int result;
// /**
// * success message of command result *
// */
// public String successMsg;
// /**
// * error message of command result *
// */
// public String errorMsg;
//
// public CommandResult(int result) {
// this.result = result;
// }
//
// public CommandResult(int result, String successMsg, String errorMsg) {
// this.result = result;
// this.successMsg = successMsg;
// this.errorMsg = errorMsg;
// }
// }
// Path: util/src/main/java/com/ihongqiqu/util/PackageUtils.java
import com.ihongqiqu.util.ShellUtils.CommandResult;
import java.io.File;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
* app.</li>
* </ul>
*
* @param context
* @param filePath file path of package
* @param pmParams pm install params
* @return {@link PackageUtils#INSTALL_SUCCEEDED} means install success,
* other means failed. details see {@link PackageUtils}
* .INSTALL_FAILED_*. same to {@link PackageManager}.INSTALL_*
*/
public static int installSilent(Context context, String filePath,
String pmParams) {
if (filePath == null || filePath.length() == 0) {
return INSTALL_FAILED_INVALID_URI;
}
File file = new File(filePath);
if (file.length() <= 0 || !file.exists() || !file.isFile()) {
return INSTALL_FAILED_INVALID_URI;
}
/**
* if context is system app, don't need root permission, but should add
* <uses-permission android:name="android.permission.INSTALL_PACKAGES"
* /> in mainfest
**/
StringBuilder command = new StringBuilder()
.append("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm install ")
.append(pmParams == null ? "" : pmParams).append(" ")
.append(filePath.replace(" ", "\\ ")); | CommandResult commandResult = ShellUtils.execCommand( |
Lordmau5/FFS | unused/api/java/dan200/computercraft/api/media/IMedia.java | // Path: unused/api/java/dan200/computercraft/api/filesystem/IMount.java
// public interface IMount
// {
// /**
// * Returns whether a file with a given path exists or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return true if the file exists, false otherwise
// */
// public boolean exists( String path ) throws IOException;
//
// /**
// * Returns whether a file with a given path is a directory or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @return true if the file exists and is a directory, false otherwise
// */
// public boolean isDirectory( String path ) throws IOException;
//
// /**
// * Returns the file names of all the files in a directory.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @param contents A list of strings. Add all the file names to this list
// */
// public void list( String path, List<String> contents ) throws IOException;
//
// /**
// * Returns the size of a file with a given path, in bytes
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return the size of the file, in bytes
// */
// public long getSize( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an inputstream representing it's contents.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream representing the contents of the file
// */
// public InputStream openForRead( String path ) throws IOException;
// }
| import dan200.computercraft.api.filesystem.IMount;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World; | /**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.media;
/**
* Represents an item that can be placed in a disk drive and used by a Computer.
* Implement this interface on your Item class to allow it to be used in the drive.
*/
public interface IMedia
{
/**
* Get a string representing the label of this item. Will be called vi disk.getLabel() in lua.
* @param stack The itemstack to inspect
* @return The label. ie: "Dan's Programs"
*/
public String getLabel( ItemStack stack );
/**
* Set a string representing the label of this item. Will be called vi disk.setLabel() in lua.
* @param stack The itemstack to modify.
* @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified.
*/
public boolean setLabel( ItemStack stack, String label );
/**
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: "Jonathon Coulton - Still Alive"
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioTitle( ItemStack stack );
/**
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioRecordName( ItemStack stack );
/**
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will be mounted onto the filesystem of the computercraft while the media is in the disk drive.
* @param stack The itemstack to inspect.
* @param world The world in which the item and disk drive reside.
* @return The mount, or null if this item does not represent an item with data. If the IMount returned also implements IWritableMount, it will mounted using mountWritable()
* @see dan200.computercraft.api.filesystem.IMount
* @see dan200.computercraft.api.filesystem.IWritableMount
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
*/ | // Path: unused/api/java/dan200/computercraft/api/filesystem/IMount.java
// public interface IMount
// {
// /**
// * Returns whether a file with a given path exists or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return true if the file exists, false otherwise
// */
// public boolean exists( String path ) throws IOException;
//
// /**
// * Returns whether a file with a given path is a directory or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @return true if the file exists and is a directory, false otherwise
// */
// public boolean isDirectory( String path ) throws IOException;
//
// /**
// * Returns the file names of all the files in a directory.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @param contents A list of strings. Add all the file names to this list
// */
// public void list( String path, List<String> contents ) throws IOException;
//
// /**
// * Returns the size of a file with a given path, in bytes
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return the size of the file, in bytes
// */
// public long getSize( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an inputstream representing it's contents.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream representing the contents of the file
// */
// public InputStream openForRead( String path ) throws IOException;
// }
// Path: unused/api/java/dan200/computercraft/api/media/IMedia.java
import dan200.computercraft.api.filesystem.IMount;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.media;
/**
* Represents an item that can be placed in a disk drive and used by a Computer.
* Implement this interface on your Item class to allow it to be used in the drive.
*/
public interface IMedia
{
/**
* Get a string representing the label of this item. Will be called vi disk.getLabel() in lua.
* @param stack The itemstack to inspect
* @return The label. ie: "Dan's Programs"
*/
public String getLabel( ItemStack stack );
/**
* Set a string representing the label of this item. Will be called vi disk.setLabel() in lua.
* @param stack The itemstack to modify.
* @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified.
*/
public boolean setLabel( ItemStack stack, String label );
/**
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: "Jonathon Coulton - Still Alive"
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioTitle( ItemStack stack );
/**
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioRecordName( ItemStack stack );
/**
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will be mounted onto the filesystem of the computercraft while the media is in the disk drive.
* @param stack The itemstack to inspect.
* @param world The world in which the item and disk drive reside.
* @return The mount, or null if this item does not represent an item with data. If the IMount returned also implements IWritableMount, it will mounted using mountWritable()
* @see dan200.computercraft.api.filesystem.IMount
* @see dan200.computercraft.api.filesystem.IWritableMount
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
*/ | public IMount createDataMount( ItemStack stack, World world ); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack; | package com.lordmau5.ffs.client;
/**
* Created by Gigabit101 on 01/08/2017.
*/
public class CreativeTabFFS extends CreativeTabs {
public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
public CreativeTabFFS() { | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
package com.lordmau5.ffs.client;
/**
* Created by Gigabit101 on 01/08/2017.
*/
public class CreativeTabFFS extends CreativeTabs {
public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
public CreativeTabFFS() { | super(FancyFluidStorage.MODID); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/proxy/CommonProxy.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; | package com.lordmau5.ffs.proxy;
/**
* Created by Dustin on 29.06.2015.
*/
public class CommonProxy implements IProxy {
public void preInit() {
}
public void init(FMLInitializationEvent event) { | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/proxy/CommonProxy.java
import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
package com.lordmau5.ffs.proxy;
/**
* Created by Dustin on 29.06.2015.
*/
public class CommonProxy implements IProxy {
public void preInit() {
}
public void init(FMLInitializationEvent event) { | MinecraftForge.EVENT_BUS.register(new FancyFluidStorage()); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/item/ItemTitEgg.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item; | package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTitEgg extends Item {
public ItemTitEgg() {
setRegistryName("item_tit_egg"); | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
// Path: src/main/java/com/lordmau5/ffs/item/ItemTitEgg.java
import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item;
package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTitEgg extends Item {
public ItemTitEgg() {
setRegistryName("item_tit_egg"); | setTranslationKey(FancyFluidStorage.MODID + ".item_tit_egg"); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/item/ItemTitEgg.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item; | package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTitEgg extends Item {
public ItemTitEgg() {
setRegistryName("item_tit_egg");
setTranslationKey(FancyFluidStorage.MODID + ".item_tit_egg"); | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
// Path: src/main/java/com/lordmau5/ffs/item/ItemTitEgg.java
import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item;
package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTitEgg extends Item {
public ItemTitEgg() {
setRegistryName("item_tit_egg");
setTranslationKey(FancyFluidStorage.MODID + ".item_tit_egg"); | setCreativeTab(CreativeTabFFS.INSTANCE); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/item/ItemTit.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item; | package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTit extends Item {
public ItemTit() {
setRegistryName("item_tit"); | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
// Path: src/main/java/com/lordmau5/ffs/item/ItemTit.java
import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item;
package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTit extends Item {
public ItemTit() {
setRegistryName("item_tit"); | setTranslationKey(FancyFluidStorage.MODID + ".item_tit"); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/item/ItemTit.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item; | package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTit extends Item {
public ItemTit() {
setRegistryName("item_tit");
setTranslationKey(FancyFluidStorage.MODID + ".item_tit"); | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/client/CreativeTabFFS.java
// public class CreativeTabFFS extends CreativeTabs {
// public static CreativeTabFFS INSTANCE = new CreativeTabFFS();
//
// public CreativeTabFFS() {
// super(FancyFluidStorage.MODID);
// }
//
// @Override
// public ItemStack createIcon() {
// return new ItemStack(FancyFluidStorage.blockFluidValve);
// }
// }
// Path: src/main/java/com/lordmau5/ffs/item/ItemTit.java
import com.lordmau5.ffs.FancyFluidStorage;
import com.lordmau5.ffs.client.CreativeTabFFS;
import net.minecraft.item.Item;
package com.lordmau5.ffs.item;
/**
* Created by Lordmau5 on 08.12.2016.
*/
public class ItemTit extends Item {
public ItemTit() {
setRegistryName("item_tit");
setTranslationKey(FancyFluidStorage.MODID + ".item_tit"); | setCreativeTab(CreativeTabFFS.INSTANCE); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/compat/top/TOPCompatibility.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraftforge.fml.common.event.FMLInterModComms; | package com.lordmau5.ffs.compat.top;
/**
* Created by Lordmau5 on 07.10.2016.
*/
public class TOPCompatibility {
public static final String modid = "theoneprobe";
public static void register() { | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/compat/top/TOPCompatibility.java
import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraftforge.fml.common.event.FMLInterModComms;
package com.lordmau5.ffs.compat.top;
/**
* Created by Lordmau5 on 07.10.2016.
*/
public class TOPCompatibility {
public static final String modid = "theoneprobe";
public static void register() { | FMLInterModComms.sendFunctionMessage(FancyFluidStorage.MODID, "getTheOneProbe", "com.lordmau5.ffs.compat.top.GetTheOneProbe"); |
Lordmau5/FFS | unused/api/java/dan200/computercraft/api/peripheral/IPeripheral.java | // Path: unused/api/java/dan200/computercraft/api/lua/ILuaContext.java
// public interface ILuaContext
// {
// /**
// * Wait for an event to occur on the computercraft, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
// * Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// */
// public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
//
// /**
// * The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] pullEventRaw( String filter ) throws InterruptedException;
//
// /**
// * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
// * @param arguments An object array containing the arguments to pass to coroutine.yield()
// * @return An object array containing the return values from coroutine.yield()
// * @throws InterruptedException If the user shuts down or reboots the computercraft the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] yield( Object[] arguments ) throws InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public long issueMainThreadTask( ILuaTask task ) throws LuaException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/lua/LuaException.java
// public class LuaException extends Exception
// {
// private final int m_level;
//
// public LuaException()
// {
// this( "error", 1 );
// }
//
// public LuaException( String message )
// {
// this( message, 1 );
// }
//
// public LuaException( String message, int level )
// {
// super( message );
// m_level = level;
// }
//
// public int getLevel()
// {
// return m_level;
// }
// }
| import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; | /**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface that defines a peripheral. See IPeripheralProvider for how to associate blocks with peripherals.
*/
public interface IPeripheral
{
/**
* Should return a string that uniquely identifies this type of peripheral.
* This can be queried from lua by calling peripheral.getType()
* @return A string identifying the type of peripheral.
*/
public String getType();
/**
* Should return an array of strings that identify the methods that this
* peripheral exposes to Lua. This will be called once before each attachment,
* and should not change when called multiple times.
* @return An array of strings representing method names.
* @see #callMethod
*/
public String[] getMethodNames();
/**
* This is called when a lua program on an attached computercraft calls peripheral.call() with
* one of the methods exposed by getMethodNames().<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param context The context of the currently running lua thread. This can be used to wait for events
* or otherwise yield.
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
* wishes to call. The integer indicates the index into the getMethodNames() table
* that corresponds to the string passed into peripheral.call()
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
* Lua values of type "string" will be represented by Object type String.<br>
* Lua values of type "number" will be represented by Object type Double.<br>
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
* Lua values of any other type will be represented by a null object.<br>
* This array will be empty if no arguments are passed.
* @return An array of objects, representing values you wish to return to the lua program.<br>
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
* All other types will be converted to nil.<br>
* You may return null to indicate no values should be returned.
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
* same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method.
* @see #getMethodNames
*/ | // Path: unused/api/java/dan200/computercraft/api/lua/ILuaContext.java
// public interface ILuaContext
// {
// /**
// * Wait for an event to occur on the computercraft, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
// * Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// */
// public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
//
// /**
// * The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] pullEventRaw( String filter ) throws InterruptedException;
//
// /**
// * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
// * @param arguments An object array containing the arguments to pass to coroutine.yield()
// * @return An object array containing the return values from coroutine.yield()
// * @throws InterruptedException If the user shuts down or reboots the computercraft the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] yield( Object[] arguments ) throws InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public long issueMainThreadTask( ILuaTask task ) throws LuaException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/lua/LuaException.java
// public class LuaException extends Exception
// {
// private final int m_level;
//
// public LuaException()
// {
// this( "error", 1 );
// }
//
// public LuaException( String message )
// {
// this( message, 1 );
// }
//
// public LuaException( String message, int level )
// {
// super( message );
// m_level = level;
// }
//
// public int getLevel()
// {
// return m_level;
// }
// }
// Path: unused/api/java/dan200/computercraft/api/peripheral/IPeripheral.java
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface that defines a peripheral. See IPeripheralProvider for how to associate blocks with peripherals.
*/
public interface IPeripheral
{
/**
* Should return a string that uniquely identifies this type of peripheral.
* This can be queried from lua by calling peripheral.getType()
* @return A string identifying the type of peripheral.
*/
public String getType();
/**
* Should return an array of strings that identify the methods that this
* peripheral exposes to Lua. This will be called once before each attachment,
* and should not change when called multiple times.
* @return An array of strings representing method names.
* @see #callMethod
*/
public String[] getMethodNames();
/**
* This is called when a lua program on an attached computercraft calls peripheral.call() with
* one of the methods exposed by getMethodNames().<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param context The context of the currently running lua thread. This can be used to wait for events
* or otherwise yield.
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
* wishes to call. The integer indicates the index into the getMethodNames() table
* that corresponds to the string passed into peripheral.call()
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
* Lua values of type "string" will be represented by Object type String.<br>
* Lua values of type "number" will be represented by Object type Double.<br>
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
* Lua values of any other type will be represented by a null object.<br>
* This array will be empty if no arguments are passed.
* @return An array of objects, representing values you wish to return to the lua program.<br>
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
* All other types will be converted to nil.<br>
* You may return null to indicate no values should be returned.
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
* same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method.
* @see #getMethodNames
*/ | public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException; |
Lordmau5/FFS | unused/api/java/dan200/computercraft/api/peripheral/IPeripheral.java | // Path: unused/api/java/dan200/computercraft/api/lua/ILuaContext.java
// public interface ILuaContext
// {
// /**
// * Wait for an event to occur on the computercraft, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
// * Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// */
// public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
//
// /**
// * The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] pullEventRaw( String filter ) throws InterruptedException;
//
// /**
// * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
// * @param arguments An object array containing the arguments to pass to coroutine.yield()
// * @return An object array containing the return values from coroutine.yield()
// * @throws InterruptedException If the user shuts down or reboots the computercraft the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] yield( Object[] arguments ) throws InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public long issueMainThreadTask( ILuaTask task ) throws LuaException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/lua/LuaException.java
// public class LuaException extends Exception
// {
// private final int m_level;
//
// public LuaException()
// {
// this( "error", 1 );
// }
//
// public LuaException( String message )
// {
// this( message, 1 );
// }
//
// public LuaException( String message, int level )
// {
// super( message );
// m_level = level;
// }
//
// public int getLevel()
// {
// return m_level;
// }
// }
| import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; | /**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface that defines a peripheral. See IPeripheralProvider for how to associate blocks with peripherals.
*/
public interface IPeripheral
{
/**
* Should return a string that uniquely identifies this type of peripheral.
* This can be queried from lua by calling peripheral.getType()
* @return A string identifying the type of peripheral.
*/
public String getType();
/**
* Should return an array of strings that identify the methods that this
* peripheral exposes to Lua. This will be called once before each attachment,
* and should not change when called multiple times.
* @return An array of strings representing method names.
* @see #callMethod
*/
public String[] getMethodNames();
/**
* This is called when a lua program on an attached computercraft calls peripheral.call() with
* one of the methods exposed by getMethodNames().<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param context The context of the currently running lua thread. This can be used to wait for events
* or otherwise yield.
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
* wishes to call. The integer indicates the index into the getMethodNames() table
* that corresponds to the string passed into peripheral.call()
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
* Lua values of type "string" will be represented by Object type String.<br>
* Lua values of type "number" will be represented by Object type Double.<br>
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
* Lua values of any other type will be represented by a null object.<br>
* This array will be empty if no arguments are passed.
* @return An array of objects, representing values you wish to return to the lua program.<br>
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
* All other types will be converted to nil.<br>
* You may return null to indicate no values should be returned.
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
* same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method.
* @see #getMethodNames
*/ | // Path: unused/api/java/dan200/computercraft/api/lua/ILuaContext.java
// public interface ILuaContext
// {
// /**
// * Wait for an event to occur on the computercraft, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
// * Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// */
// public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
//
// /**
// * The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
// * @param filter A specific event to wait for, or null to wait for any event
// * @return An object array containing the name of the event that occurred, and any event parameters
// * @throws InterruptedException If the user shuts down or reboots the computercraft while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] pullEventRaw( String filter ) throws InterruptedException;
//
// /**
// * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
// * @param arguments An object array containing the arguments to pass to coroutine.yield()
// * @return An object array containing the return values from coroutine.yield()
// * @throws InterruptedException If the user shuts down or reboots the computercraft the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
// * @see #pullEvent(String)
// */
// public Object[] yield( Object[] arguments ) throws InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
//
// /**
// * TODO: Document me
// * @param task
// * @return
// */
// public long issueMainThreadTask( ILuaTask task ) throws LuaException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/lua/LuaException.java
// public class LuaException extends Exception
// {
// private final int m_level;
//
// public LuaException()
// {
// this( "error", 1 );
// }
//
// public LuaException( String message )
// {
// this( message, 1 );
// }
//
// public LuaException( String message, int level )
// {
// super( message );
// m_level = level;
// }
//
// public int getLevel()
// {
// return m_level;
// }
// }
// Path: unused/api/java/dan200/computercraft/api/peripheral/IPeripheral.java
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface that defines a peripheral. See IPeripheralProvider for how to associate blocks with peripherals.
*/
public interface IPeripheral
{
/**
* Should return a string that uniquely identifies this type of peripheral.
* This can be queried from lua by calling peripheral.getType()
* @return A string identifying the type of peripheral.
*/
public String getType();
/**
* Should return an array of strings that identify the methods that this
* peripheral exposes to Lua. This will be called once before each attachment,
* and should not change when called multiple times.
* @return An array of strings representing method names.
* @see #callMethod
*/
public String[] getMethodNames();
/**
* This is called when a lua program on an attached computercraft calls peripheral.call() with
* one of the methods exposed by getMethodNames().<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param context The context of the currently running lua thread. This can be used to wait for events
* or otherwise yield.
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
* wishes to call. The integer indicates the index into the getMethodNames() table
* that corresponds to the string passed into peripheral.call()
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
* Lua values of type "string" will be represented by Object type String.<br>
* Lua values of type "number" will be represented by Object type Double.<br>
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
* Lua values of any other type will be represented by a null object.<br>
* This array will be empty if no arguments are passed.
* @return An array of objects, representing values you wish to return to the lua program.<br>
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
* All other types will be converted to nil.<br>
* You may return null to indicate no values should be returned.
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
* same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method.
* @see #getMethodNames
*/ | public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException; |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/network/NetworkHandler.java | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
| import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap; | package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
| // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/network/NetworkHandler.java
import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap;
package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
| pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server()); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/network/NetworkHandler.java | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
| import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap; | package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server()); | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/network/NetworkHandler.java
import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap;
package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server()); | pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server()); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/network/NetworkHandler.java | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
| import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap; | package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server());
pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server());
| // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/network/NetworkHandler.java
import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap;
package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server());
pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server());
| pipeline.addAfter(targetName, "OnTankRequest", new OnTankRequest()); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/network/NetworkHandler.java | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
| import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap; | package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server());
pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server());
pipeline.addAfter(targetName, "OnTankRequest", new OnTankRequest());
if ( side.isClient() ) {
registerClientHandlers();
}
}
@SideOnly(Side.CLIENT)
private static void registerClientHandlers() {
ChannelPipeline pipeline = channels.get(Side.CLIENT).pipeline();
String targetName = channels.get(Side.CLIENT).findChannelHandlerNameForType(PacketCodec.class);
| // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/network/NetworkHandler.java
import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap;
package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server());
pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server());
pipeline.addAfter(targetName, "OnTankRequest", new OnTankRequest());
if ( side.isClient() ) {
registerClientHandlers();
}
}
@SideOnly(Side.CLIENT)
private static void registerClientHandlers() {
ChannelPipeline pipeline = channels.get(Side.CLIENT).pipeline();
String targetName = channels.get(Side.CLIENT).findChannelHandlerNameForType(PacketCodec.class);
| pipeline.addAfter(targetName, "OnTankBuild", new OnTankBuild()); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/network/NetworkHandler.java | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
| import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap; | package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server());
pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server());
pipeline.addAfter(targetName, "OnTankRequest", new OnTankRequest());
if ( side.isClient() ) {
registerClientHandlers();
}
}
@SideOnly(Side.CLIENT)
private static void registerClientHandlers() {
ChannelPipeline pipeline = channels.get(Side.CLIENT).pipeline();
String targetName = channels.get(Side.CLIENT).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "OnTankBuild", new OnTankBuild()); | // Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBreak.java
// public class OnTankBreak extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBreak> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBreak msg) throws Exception {
// FancyFluidStorage.tankManager.remove(msg.getDimension(), msg.getValvePos());
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/client/OnTankBuild.java
// public class OnTankBuild extends SimpleChannelInboundHandler<FFSPacket.Client.OnTankBuild> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Client.OnTankBuild msg) throws Exception {
// if ( Minecraft.getMinecraft().world != null ) {
// TileEntity tile = Minecraft.getMinecraft().world.getTileEntity(msg.getValvePos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// FancyFluidStorage.tankManager.add(Minecraft.getMinecraft().world, msg.getValvePos(), msg.getAirBlocks(), msg.getFrameBlocks());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/OnTankRequest.java
// public class OnTankRequest extends SimpleChannelInboundHandler<FFSPacket.Server.OnTankRequest> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.OnTankRequest msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// NetworkHandler.sendPacketToPlayer(new FFSPacket.Client.OnTankBuild((AbstractTankValve) tile), NetworkHandler.getPlayer(ctx));
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateFluidLock_Server.java
// public class UpdateFluidLock_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateFluidLock> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateFluidLock msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity tile = world.getTileEntity(msg.getPos());
// if ( tile != null && tile instanceof AbstractTankValve ) {
// AbstractTankValve valve = (AbstractTankValve) tile;
// valve.toggleFluidLock(msg.isFluidLock());
// }
// }
// }
// }
//
// Path: src/main/java/com/lordmau5/ffs/network/handlers/server/UpdateTileName_Server.java
// public class UpdateTileName_Server extends SimpleChannelInboundHandler<FFSPacket.Server.UpdateTileName> {
//
// @Override
// protected void channelRead0(ChannelHandlerContext ctx, FFSPacket.Server.UpdateTileName msg) throws Exception {
// World world = NetworkHandler.getPlayer(ctx).getEntityWorld();
// if ( world != null ) {
// TileEntity w_Tile = world.getTileEntity(msg.getPos());
// if ( w_Tile != null && w_Tile instanceof AbstractTankTile && w_Tile instanceof INameableTile ) {
// AbstractTankTile tile = (AbstractTankTile) w_Tile;
// ((INameableTile) tile).setTileName(msg.getName());
// tile.markForUpdateNow();
// }
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/network/NetworkHandler.java
import com.lordmau5.ffs.network.handlers.client.OnTankBreak;
import com.lordmau5.ffs.network.handlers.client.OnTankBuild;
import com.lordmau5.ffs.network.handlers.server.OnTankRequest;
import com.lordmau5.ffs.network.handlers.server.UpdateFluidLock_Server;
import com.lordmau5.ffs.network.handlers.server.UpdateTileName_Server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.EnumMap;
package com.lordmau5.ffs.network;
/**
* Created by Dustin on 07.07.2015.
*/
public class NetworkHandler {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
public static void registerChannels(Side side) {
channels = NetworkRegistry.INSTANCE.newChannel("ffs", new PacketCodec());
ChannelPipeline pipeline = channels.get(Side.SERVER).pipeline();
String targetName = channels.get(Side.SERVER).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "UpdateTileName_Server", new UpdateTileName_Server());
pipeline.addAfter(targetName, "UpdateFluidLock_Server", new UpdateFluidLock_Server());
pipeline.addAfter(targetName, "OnTankRequest", new OnTankRequest());
if ( side.isClient() ) {
registerClientHandlers();
}
}
@SideOnly(Side.CLIENT)
private static void registerClientHandlers() {
ChannelPipeline pipeline = channels.get(Side.CLIENT).pipeline();
String targetName = channels.get(Side.CLIENT).findChannelHandlerNameForType(PacketCodec.class);
pipeline.addAfter(targetName, "OnTankBuild", new OnTankBuild()); | pipeline.addAfter(targetName, "OnTankBreak", new OnTankBreak()); |
Lordmau5/FFS | unused/api/java/dan200/computercraft/api/peripheral/IComputerAccess.java | // Path: unused/api/java/dan200/computercraft/api/filesystem/IMount.java
// public interface IMount
// {
// /**
// * Returns whether a file with a given path exists or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return true if the file exists, false otherwise
// */
// public boolean exists( String path ) throws IOException;
//
// /**
// * Returns whether a file with a given path is a directory or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @return true if the file exists and is a directory, false otherwise
// */
// public boolean isDirectory( String path ) throws IOException;
//
// /**
// * Returns the file names of all the files in a directory.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @param contents A list of strings. Add all the file names to this list
// */
// public void list( String path, List<String> contents ) throws IOException;
//
// /**
// * Returns the size of a file with a given path, in bytes
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return the size of the file, in bytes
// */
// public long getSize( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an inputstream representing it's contents.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream representing the contents of the file
// */
// public InputStream openForRead( String path ) throws IOException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/filesystem/IWritableMount.java
// public interface IWritableMount extends IMount
// {
// /**
// * Creates a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
// */
// public void makeDirectory( String path ) throws IOException;
//
// /**
// * Deletes a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
// */
// public void delete( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for writing to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForWrite( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for appending to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForAppend( String path ) throws IOException;
//
// /**
// * Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
// * @return The ammount of free space, in bytes.
// */
// public long getRemainingSpace() throws IOException;
// }
| import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount; | /**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact
* with computers except via this interface.
*/
public interface IComputerAccess
{
/**
* Mount a mount onto the computers' file system in a read only mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see #unmount(String)
* @see dan200.computercraft.api.filesystem.IMount
*/ | // Path: unused/api/java/dan200/computercraft/api/filesystem/IMount.java
// public interface IMount
// {
// /**
// * Returns whether a file with a given path exists or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return true if the file exists, false otherwise
// */
// public boolean exists( String path ) throws IOException;
//
// /**
// * Returns whether a file with a given path is a directory or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @return true if the file exists and is a directory, false otherwise
// */
// public boolean isDirectory( String path ) throws IOException;
//
// /**
// * Returns the file names of all the files in a directory.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @param contents A list of strings. Add all the file names to this list
// */
// public void list( String path, List<String> contents ) throws IOException;
//
// /**
// * Returns the size of a file with a given path, in bytes
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return the size of the file, in bytes
// */
// public long getSize( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an inputstream representing it's contents.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream representing the contents of the file
// */
// public InputStream openForRead( String path ) throws IOException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/filesystem/IWritableMount.java
// public interface IWritableMount extends IMount
// {
// /**
// * Creates a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
// */
// public void makeDirectory( String path ) throws IOException;
//
// /**
// * Deletes a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
// */
// public void delete( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for writing to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForWrite( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for appending to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForAppend( String path ) throws IOException;
//
// /**
// * Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
// * @return The ammount of free space, in bytes.
// */
// public long getRemainingSpace() throws IOException;
// }
// Path: unused/api/java/dan200/computercraft/api/peripheral/IComputerAccess.java
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount;
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact
* with computers except via this interface.
*/
public interface IComputerAccess
{
/**
* Mount a mount onto the computers' file system in a read only mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see #unmount(String)
* @see dan200.computercraft.api.filesystem.IMount
*/ | public String mount( String desiredLocation, IMount mount ); |
Lordmau5/FFS | unused/api/java/dan200/computercraft/api/peripheral/IComputerAccess.java | // Path: unused/api/java/dan200/computercraft/api/filesystem/IMount.java
// public interface IMount
// {
// /**
// * Returns whether a file with a given path exists or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return true if the file exists, false otherwise
// */
// public boolean exists( String path ) throws IOException;
//
// /**
// * Returns whether a file with a given path is a directory or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @return true if the file exists and is a directory, false otherwise
// */
// public boolean isDirectory( String path ) throws IOException;
//
// /**
// * Returns the file names of all the files in a directory.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @param contents A list of strings. Add all the file names to this list
// */
// public void list( String path, List<String> contents ) throws IOException;
//
// /**
// * Returns the size of a file with a given path, in bytes
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return the size of the file, in bytes
// */
// public long getSize( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an inputstream representing it's contents.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream representing the contents of the file
// */
// public InputStream openForRead( String path ) throws IOException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/filesystem/IWritableMount.java
// public interface IWritableMount extends IMount
// {
// /**
// * Creates a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
// */
// public void makeDirectory( String path ) throws IOException;
//
// /**
// * Deletes a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
// */
// public void delete( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for writing to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForWrite( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for appending to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForAppend( String path ) throws IOException;
//
// /**
// * Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
// * @return The ammount of free space, in bytes.
// */
// public long getRemainingSpace() throws IOException;
// }
| import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount; | /**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact
* with computers except via this interface.
*/
public interface IComputerAccess
{
/**
* Mount a mount onto the computers' file system in a read only mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see #unmount(String)
* @see dan200.computercraft.api.filesystem.IMount
*/
public String mount( String desiredLocation, IMount mount );
/**
* TODO: Document me
*/
public String mount( String desiredLocation, IMount mount, String driveName );
/**
* Mount a mount onto the computers' file system in a writable mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mount(String, IMount)
* @see #unmount(String)
* @see IMount
*/ | // Path: unused/api/java/dan200/computercraft/api/filesystem/IMount.java
// public interface IMount
// {
// /**
// * Returns whether a file with a given path exists or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return true if the file exists, false otherwise
// */
// public boolean exists( String path ) throws IOException;
//
// /**
// * Returns whether a file with a given path is a directory or not.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @return true if the file exists and is a directory, false otherwise
// */
// public boolean isDirectory( String path ) throws IOException;
//
// /**
// * Returns the file names of all the files in a directory.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
// * @param contents A list of strings. Add all the file names to this list
// */
// public void list( String path, List<String> contents ) throws IOException;
//
// /**
// * Returns the size of a file with a given path, in bytes
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return the size of the file, in bytes
// */
// public long getSize( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an inputstream representing it's contents.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream representing the contents of the file
// */
// public InputStream openForRead( String path ) throws IOException;
// }
//
// Path: unused/api/java/dan200/computercraft/api/filesystem/IWritableMount.java
// public interface IWritableMount extends IMount
// {
// /**
// * Creates a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
// */
// public void makeDirectory( String path ) throws IOException;
//
// /**
// * Deletes a directory at a given path inside the virtual file system.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
// */
// public void delete( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for writing to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForWrite( String path ) throws IOException;
//
// /**
// * Opens a file with a given path, and returns an outputstream for appending to it.
// * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
// * @return a stream for writing to
// */
// public OutputStream openForAppend( String path ) throws IOException;
//
// /**
// * Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
// * @return The ammount of free space, in bytes.
// */
// public long getRemainingSpace() throws IOException;
// }
// Path: unused/api/java/dan200/computercraft/api/peripheral/IComputerAccess.java
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount;
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
/**
* The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact
* with computers except via this interface.
*/
public interface IComputerAccess
{
/**
* Mount a mount onto the computers' file system in a read only mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see #unmount(String)
* @see dan200.computercraft.api.filesystem.IMount
*/
public String mount( String desiredLocation, IMount mount );
/**
* TODO: Document me
*/
public String mount( String desiredLocation, IMount mount, String driveName );
/**
* Mount a mount onto the computers' file system in a writable mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mount(String, IMount)
* @see #unmount(String)
* @see IMount
*/ | public String mountWritable( String desiredLocation, IWritableMount mount ); |
Lordmau5/FFS | src/main/java/com/lordmau5/ffs/init/ModRecipes.java | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
| import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry; | package com.lordmau5.ffs.init;
/**
* Created by Gigabit101 on 31/07/2017.
*/
public class ModRecipes {
public static void init() { | // Path: src/main/java/com/lordmau5/ffs/FancyFluidStorage.java
// @Mod(modid = FancyFluidStorage.MODID, name = "Fancy Fluid Storage", dependencies = "after:waila")
// public class FancyFluidStorage {
// public static final String MODID = "ffs";
// public static final TankManager tankManager = new TankManager();
// public static Block blockFluidValve;
// public static Block blockTankComputer;
// public static Item itemTitEgg;
// public static Item itemTit;
// @Mod.Instance(MODID)
// public static FancyFluidStorage INSTANCE;
//
// @SidedProxy(clientSide = "com.lordmau5.ffs.proxy.ClientProxy", serverSide = "com.lordmau5.ffs.proxy.CommonProxy")
// private static IProxy PROXY;
//
// @SuppressWarnings("deprecation")
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Compatibility.INSTANCE.init();
//
// ModBlocksAndItems.preInit(event);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(FancyFluidStorage.INSTANCE, new GuiHandler());
// NetworkHandler.registerChannels(event.getSide());
//
// TOPCompatibility.register();
//
// PROXY.preInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// ModRecipes.init();
//
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// GenericUtil.init();
//
// ForgeChunkManager.setForcedChunkLoadingCallback(INSTANCE, (tickets, world) -> {
// if ( tickets != null && tickets.size() > 0 )
// GenericUtil.initChunkLoadTicket(world, tickets.get(0));
// });
// }
//
// @SubscribeEvent
// public void onWorldUnload(WorldEvent.Unload event) {
// if ( event.getWorld().isRemote ) {
// FancyFluidStorage.tankManager.removeAllForDimension(event.getWorld().provider.getDimension());
// }
// }
// }
// Path: src/main/java/com/lordmau5/ffs/init/ModRecipes.java
import com.lordmau5.ffs.FancyFluidStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
package com.lordmau5.ffs.init;
/**
* Created by Gigabit101 on 31/07/2017.
*/
public class ModRecipes {
public static void init() { | GameRegistry.addSmelting(FancyFluidStorage.itemTitEgg, new ItemStack(FancyFluidStorage.itemTit), 0); |
tfiskgul/mux2fs | core/src/main/java/se/tfiskgul/mux2fs/mux/MuxedFile.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileInfo.java
// @Immutable
// public class FileInfo {
//
// private final long inode;
// private final FileTime mtime;
// private final FileTime ctime;
// private final long size;
//
// public FileInfo(long inode, FileTime mtime, FileTime ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = mtime;
// this.ctime = ctime;
// this.size = size;
// }
//
// public FileInfo(long inode, Instant mtime, Instant ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = FileTime.from(mtime);
// this.ctime = FileTime.from(ctime);
// this.size = size;
// }
//
// public static FileInfo of(Path path)
// throws IOException {
// Map<String, Object> attributes = Files.readAttributes(path, "unix:*"); // Follow links in this case
// return new FileInfo((long) attributes.get("ino"), (FileTime) attributes.get("lastModifiedTime"), (FileTime) attributes.get("ctime"),
// (long) attributes.get("size"));
// }
//
// public long getInode() {
// return inode;
// }
//
// public FileTime getMtime() {
// return mtime;
// }
//
// public FileTime getCtime() {
// return ctime;
// }
//
// public long getSize() {
// return size;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(inode, mtime, ctime, size);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// FileInfo other = (FileInfo) obj;
// return Objects.equals(inode, other.inode) && Objects.equals(mtime, other.mtime) && Objects.equals(ctime, other.ctime)
// && Objects.equals(size, other.size);
// }
//
// @Override
// public String toString() {
// return "FileInfo [inode=" + inode + ", mtime=" + mtime + ", ctime=" + ctime + ", size=" + size + "]";
// }
// }
| import java.util.Objects;
import javax.annotation.concurrent.Immutable;
import se.tfiskgul.mux2fs.fs.base.FileInfo; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.mux;
@Immutable
public class MuxedFile {
| // Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileInfo.java
// @Immutable
// public class FileInfo {
//
// private final long inode;
// private final FileTime mtime;
// private final FileTime ctime;
// private final long size;
//
// public FileInfo(long inode, FileTime mtime, FileTime ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = mtime;
// this.ctime = ctime;
// this.size = size;
// }
//
// public FileInfo(long inode, Instant mtime, Instant ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = FileTime.from(mtime);
// this.ctime = FileTime.from(ctime);
// this.size = size;
// }
//
// public static FileInfo of(Path path)
// throws IOException {
// Map<String, Object> attributes = Files.readAttributes(path, "unix:*"); // Follow links in this case
// return new FileInfo((long) attributes.get("ino"), (FileTime) attributes.get("lastModifiedTime"), (FileTime) attributes.get("ctime"),
// (long) attributes.get("size"));
// }
//
// public long getInode() {
// return inode;
// }
//
// public FileTime getMtime() {
// return mtime;
// }
//
// public FileTime getCtime() {
// return ctime;
// }
//
// public long getSize() {
// return size;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(inode, mtime, ctime, size);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// FileInfo other = (FileInfo) obj;
// return Objects.equals(inode, other.inode) && Objects.equals(mtime, other.mtime) && Objects.equals(ctime, other.ctime)
// && Objects.equals(size, other.size);
// }
//
// @Override
// public String toString() {
// return "FileInfo [inode=" + inode + ", mtime=" + mtime + ", ctime=" + ctime + ", size=" + size + "]";
// }
// }
// Path: core/src/main/java/se/tfiskgul/mux2fs/mux/MuxedFile.java
import java.util.Objects;
import javax.annotation.concurrent.Immutable;
import se.tfiskgul.mux2fs.fs.base.FileInfo;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.mux;
@Immutable
public class MuxedFile {
| private final FileInfo info; |
tfiskgul/mux2fs | core/src/test/java/se/tfiskgul/mux2fs/mux/MuxedFileTest.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileInfo.java
// @Immutable
// public class FileInfo {
//
// private final long inode;
// private final FileTime mtime;
// private final FileTime ctime;
// private final long size;
//
// public FileInfo(long inode, FileTime mtime, FileTime ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = mtime;
// this.ctime = ctime;
// this.size = size;
// }
//
// public FileInfo(long inode, Instant mtime, Instant ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = FileTime.from(mtime);
// this.ctime = FileTime.from(ctime);
// this.size = size;
// }
//
// public static FileInfo of(Path path)
// throws IOException {
// Map<String, Object> attributes = Files.readAttributes(path, "unix:*"); // Follow links in this case
// return new FileInfo((long) attributes.get("ino"), (FileTime) attributes.get("lastModifiedTime"), (FileTime) attributes.get("ctime"),
// (long) attributes.get("size"));
// }
//
// public long getInode() {
// return inode;
// }
//
// public FileTime getMtime() {
// return mtime;
// }
//
// public FileTime getCtime() {
// return ctime;
// }
//
// public long getSize() {
// return size;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(inode, mtime, ctime, size);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// FileInfo other = (FileInfo) obj;
// return Objects.equals(inode, other.inode) && Objects.equals(mtime, other.mtime) && Objects.equals(ctime, other.ctime)
// && Objects.equals(size, other.size);
// }
//
// @Override
// public String toString() {
// return "FileInfo [inode=" + inode + ", mtime=" + mtime + ", ctime=" + ctime + ", size=" + size + "]";
// }
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import org.junit.Test;
import se.tfiskgul.mux2fs.fs.base.FileInfo; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.mux;
public class MuxedFileTest {
@Test
public void testEquals() { | // Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileInfo.java
// @Immutable
// public class FileInfo {
//
// private final long inode;
// private final FileTime mtime;
// private final FileTime ctime;
// private final long size;
//
// public FileInfo(long inode, FileTime mtime, FileTime ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = mtime;
// this.ctime = ctime;
// this.size = size;
// }
//
// public FileInfo(long inode, Instant mtime, Instant ctime, long size) {
// super();
// this.inode = inode;
// this.mtime = FileTime.from(mtime);
// this.ctime = FileTime.from(ctime);
// this.size = size;
// }
//
// public static FileInfo of(Path path)
// throws IOException {
// Map<String, Object> attributes = Files.readAttributes(path, "unix:*"); // Follow links in this case
// return new FileInfo((long) attributes.get("ino"), (FileTime) attributes.get("lastModifiedTime"), (FileTime) attributes.get("ctime"),
// (long) attributes.get("size"));
// }
//
// public long getInode() {
// return inode;
// }
//
// public FileTime getMtime() {
// return mtime;
// }
//
// public FileTime getCtime() {
// return ctime;
// }
//
// public long getSize() {
// return size;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(inode, mtime, ctime, size);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// FileInfo other = (FileInfo) obj;
// return Objects.equals(inode, other.inode) && Objects.equals(mtime, other.mtime) && Objects.equals(ctime, other.ctime)
// && Objects.equals(size, other.size);
// }
//
// @Override
// public String toString() {
// return "FileInfo [inode=" + inode + ", mtime=" + mtime + ", ctime=" + ctime + ", size=" + size + "]";
// }
// }
// Path: core/src/test/java/se/tfiskgul/mux2fs/mux/MuxedFileTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import org.junit.Test;
import se.tfiskgul.mux2fs.fs.base.FileInfo;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.mux;
public class MuxedFileTest {
@Test
public void testEquals() { | FileInfo info = mock(FileInfo.class); |
tfiskgul/mux2fs | core/src/main/java/se/tfiskgul/mux2fs/mux/Muxer.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int MUX_WAIT_LOOP_MS = 500;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/Sleeper.java
// @FunctionalInterface
// public interface Sleeper {
//
// void sleep(int millis)
// throws InterruptedException;
// }
| import static se.tfiskgul.mux2fs.Constants.MUX_WAIT_LOOP_MS;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import static se.tfiskgul.mux2fs.mux.Muxer.State.FAILED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.NOT_STARTED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.RUNNING;
import static se.tfiskgul.mux2fs.mux.Muxer.State.SUCCESSFUL;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessMode;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import se.tfiskgul.mux2fs.fs.base.Sleeper; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.mux;
/**
* TODO: Add cancel()
*
* TODO: Support for multiple srtFiles
*/
public class Muxer {
private static final Logger logger = LoggerFactory.getLogger(Muxer.class);
private final Path mkv;
private final Path srt;
private final Path tempDir;
private final Path output;
private final AtomicReference<State> state = new AtomicReference<Muxer.State>(NOT_STARTED);
private volatile Process process;
private final ProcessBuilderFactory factory; | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int MUX_WAIT_LOOP_MS = 500;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/Sleeper.java
// @FunctionalInterface
// public interface Sleeper {
//
// void sleep(int millis)
// throws InterruptedException;
// }
// Path: core/src/main/java/se/tfiskgul/mux2fs/mux/Muxer.java
import static se.tfiskgul.mux2fs.Constants.MUX_WAIT_LOOP_MS;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import static se.tfiskgul.mux2fs.mux.Muxer.State.FAILED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.NOT_STARTED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.RUNNING;
import static se.tfiskgul.mux2fs.mux.Muxer.State.SUCCESSFUL;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessMode;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import se.tfiskgul.mux2fs.fs.base.Sleeper;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.mux;
/**
* TODO: Add cancel()
*
* TODO: Support for multiple srtFiles
*/
public class Muxer {
private static final Logger logger = LoggerFactory.getLogger(Muxer.class);
private final Path mkv;
private final Path srt;
private final Path tempDir;
private final Path output;
private final AtomicReference<State> state = new AtomicReference<Muxer.State>(NOT_STARTED);
private volatile Process process;
private final ProcessBuilderFactory factory; | private final Sleeper sleeper; |
tfiskgul/mux2fs | core/src/main/java/se/tfiskgul/mux2fs/mux/Muxer.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int MUX_WAIT_LOOP_MS = 500;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/Sleeper.java
// @FunctionalInterface
// public interface Sleeper {
//
// void sleep(int millis)
// throws InterruptedException;
// }
| import static se.tfiskgul.mux2fs.Constants.MUX_WAIT_LOOP_MS;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import static se.tfiskgul.mux2fs.mux.Muxer.State.FAILED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.NOT_STARTED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.RUNNING;
import static se.tfiskgul.mux2fs.mux.Muxer.State.SUCCESSFUL;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessMode;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import se.tfiskgul.mux2fs.fs.base.Sleeper; | access(mkv, AccessMode.READ);
access(srt, AccessMode.READ);
access(tempDir, AccessMode.WRITE);
output.toFile().deleteOnExit();
ProcessBuilder builder = factory.from("mkvmerge", "-o", output.toString(), mkv.toString(), srt.toString());
builder.directory(tempDir.toFile()).inheritIO(); // TODO: Better solution than inheritIO
process = builder.start();
} catch (Exception e) {
state.set(FAILED);
deleteWarn(output);
throw e;
}
}
}
private void deleteWarn(Path path) {
if (!path.toFile().delete()) {
logger.warn("Failed to delete {}", path);
}
}
private void access(Path path, AccessMode mode)
throws IOException {
path.getFileSystem().provider().checkAccess(path, mode);
}
public State state() {
State current = state.get();
if (current == RUNNING) {
if (process != null && !process.isAlive()) { // NOPMD | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int MUX_WAIT_LOOP_MS = 500;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/Sleeper.java
// @FunctionalInterface
// public interface Sleeper {
//
// void sleep(int millis)
// throws InterruptedException;
// }
// Path: core/src/main/java/se/tfiskgul/mux2fs/mux/Muxer.java
import static se.tfiskgul.mux2fs.Constants.MUX_WAIT_LOOP_MS;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import static se.tfiskgul.mux2fs.mux.Muxer.State.FAILED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.NOT_STARTED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.RUNNING;
import static se.tfiskgul.mux2fs.mux.Muxer.State.SUCCESSFUL;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessMode;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import se.tfiskgul.mux2fs.fs.base.Sleeper;
access(mkv, AccessMode.READ);
access(srt, AccessMode.READ);
access(tempDir, AccessMode.WRITE);
output.toFile().deleteOnExit();
ProcessBuilder builder = factory.from("mkvmerge", "-o", output.toString(), mkv.toString(), srt.toString());
builder.directory(tempDir.toFile()).inheritIO(); // TODO: Better solution than inheritIO
process = builder.start();
} catch (Exception e) {
state.set(FAILED);
deleteWarn(output);
throw e;
}
}
}
private void deleteWarn(Path path) {
if (!path.toFile().delete()) {
logger.warn("Failed to delete {}", path);
}
}
private void access(Path path, AccessMode mode)
throws IOException {
path.getFileSystem().provider().checkAccess(path, mode);
}
public State state() {
State current = state.get();
if (current == RUNNING) {
if (process != null && !process.isAlive()) { // NOPMD | if (process.exitValue() == SUCCESS) { |
tfiskgul/mux2fs | core/src/main/java/se/tfiskgul/mux2fs/mux/Muxer.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int MUX_WAIT_LOOP_MS = 500;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/Sleeper.java
// @FunctionalInterface
// public interface Sleeper {
//
// void sleep(int millis)
// throws InterruptedException;
// }
| import static se.tfiskgul.mux2fs.Constants.MUX_WAIT_LOOP_MS;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import static se.tfiskgul.mux2fs.mux.Muxer.State.FAILED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.NOT_STARTED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.RUNNING;
import static se.tfiskgul.mux2fs.mux.Muxer.State.SUCCESSFUL;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessMode;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import se.tfiskgul.mux2fs.fs.base.Sleeper; |
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Muxer other = (Muxer) obj;
return Objects.equals(mkv, other.mkv) && Objects.equals(output, other.output) && Objects.equals(srt, other.srt)
&& Objects.equals(tempDir, other.tempDir);
}
@Override
public String toString() {
return "Muxer [mkv=" + mkv + ", srt=" + srt + ", tempDirPath=" + tempDir + ", output=" + output + ", state=" + state + ", process=" + process + "]";
}
public Path getMkv() {
return mkv;
}
public boolean waitForOutput() {
final File file = output.toFile();
while (!file.isFile() && state() == RUNNING) {
try { | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int MUX_WAIT_LOOP_MS = 500;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/Sleeper.java
// @FunctionalInterface
// public interface Sleeper {
//
// void sleep(int millis)
// throws InterruptedException;
// }
// Path: core/src/main/java/se/tfiskgul/mux2fs/mux/Muxer.java
import static se.tfiskgul.mux2fs.Constants.MUX_WAIT_LOOP_MS;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import static se.tfiskgul.mux2fs.mux.Muxer.State.FAILED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.NOT_STARTED;
import static se.tfiskgul.mux2fs.mux.Muxer.State.RUNNING;
import static se.tfiskgul.mux2fs.mux.Muxer.State.SUCCESSFUL;
import java.io.File;
import java.io.IOException;
import java.nio.file.AccessMode;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import se.tfiskgul.mux2fs.fs.base.Sleeper;
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Muxer other = (Muxer) obj;
return Objects.equals(mkv, other.mkv) && Objects.equals(output, other.output) && Objects.equals(srt, other.srt)
&& Objects.equals(tempDir, other.tempDir);
}
@Override
public String toString() {
return "Muxer [mkv=" + mkv + ", srt=" + srt + ", tempDirPath=" + tempDir + ", output=" + output + ", state=" + state + ", process=" + process + "]";
}
public Path getMkv() {
return mkv;
}
public boolean waitForOutput() {
final File file = output.toFile();
while (!file.isFile() && state() == RUNNING) {
try { | sleeper.sleep(MUX_WAIT_LOOP_MS); |
tfiskgul/mux2fs | core/src/main/java/se/tfiskgul/mux2fs/fs/jnrfuse/JnrFuseWrapperFileSystem.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileSystem.java
// public interface FileSystem {
//
// String getFSName();
//
// int getattr(String path, StatFiller stat);
//
// int readdir(String path, DirectoryFiller filler);
//
// int readLink(String path, Consumer<String> buf, int size);
//
// int open(String path, FileHandleFiller filler);
//
// int read(String path, Consumer<byte[]> buf, int size, long offset, int fileHandle);
//
// int release(String path, int fileHandle);
//
// void destroy();
// }
| import jnr.ffi.types.off_t;
import jnr.ffi.types.size_t;
import ru.serce.jnrfuse.ErrorCodes;
import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.FuseStubFS;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileSystem;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.IOException;
import java.nio.file.Path;
import jnr.ffi.Pointer;
import jnr.ffi.Runtime; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.fs.jnrfuse;
public final class JnrFuseWrapperFileSystem extends FuseStubFS implements NamedJnrFuseFileSystem {
private final FileSystem delegate;
public JnrFuseWrapperFileSystem(FileSystem delegate) {
this.delegate = delegate;
}
@Override
public String getFSName() {
return delegate.getFSName();
}
@Override
public int getattr(String path, FileStat stat) {
JnrFuseUnixFileStat unixFileStat = new JnrFuseUnixFileStat();
int result = delegate.getattr(path, unixFileStat);
if (result == 0) {
unixFileStat.fill(stat);
}
return result;
}
@Override
public int readdir(String path, Pointer buf, FuseFillDir filter, long offset, FuseFileInfo fi) { | // Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileSystem.java
// public interface FileSystem {
//
// String getFSName();
//
// int getattr(String path, StatFiller stat);
//
// int readdir(String path, DirectoryFiller filler);
//
// int readLink(String path, Consumer<String> buf, int size);
//
// int open(String path, FileHandleFiller filler);
//
// int read(String path, Consumer<byte[]> buf, int size, long offset, int fileHandle);
//
// int release(String path, int fileHandle);
//
// void destroy();
// }
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/jnrfuse/JnrFuseWrapperFileSystem.java
import jnr.ffi.types.off_t;
import jnr.ffi.types.size_t;
import ru.serce.jnrfuse.ErrorCodes;
import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.FuseStubFS;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileSystem;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.IOException;
import java.nio.file.Path;
import jnr.ffi.Pointer;
import jnr.ffi.Runtime;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.fs.jnrfuse;
public final class JnrFuseWrapperFileSystem extends FuseStubFS implements NamedJnrFuseFileSystem {
private final FileSystem delegate;
public JnrFuseWrapperFileSystem(FileSystem delegate) {
this.delegate = delegate;
}
@Override
public String getFSName() {
return delegate.getFSName();
}
@Override
public int getattr(String path, FileStat stat) {
JnrFuseUnixFileStat unixFileStat = new JnrFuseUnixFileStat();
int result = delegate.getattr(path, unixFileStat);
if (result == 0) {
unixFileStat.fill(stat);
}
return result;
}
@Override
public int readdir(String path, Pointer buf, FuseFillDir filter, long offset, FuseFileInfo fi) { | DirectoryFiller filler = new FuseDirectoryFiller(buf, filter); |
tfiskgul/mux2fs | core/src/test/java/se/tfiskgul/mux2fs/ParseCommandLineTest.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/CommandLineArguments.java
// public static class Strict extends Shared {
//
// @Parameter(names = "--tempdir", description = "Temporary directory under which to mux files", required = true)
// private Path tempDir;
// @Parameter(names = "-o", description = "Options", required = false)
// private List<String> options;
// private ImmutableList<String> passThroughOptions;
// private ImmutableList<String> fuseOptions;
//
// public Path getTempDir() {
// return tempDir;
// }
//
// public void validate() {
// validateDirectoryExists(getSource());
// validateDirectoryExists(getTarget());
// File tmpDirfile = tempDir.toFile();
// if (!tmpDirfile.exists()) {
// boolean mkdirs = tmpDirfile.mkdirs();
// if (!mkdirs) {
// logger.warn("Unable to automatically create directory {}", tempDir);
// }
// }
// validateDirectoryExists(tempDir);
// }
//
// @VisibleForTesting
// List<String> getPassThroughOptions() {
// return passThroughOptions;
// }
//
// public List<String> getFuseOptions() {
// return fuseOptions;
// }
// }
| import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import com.beust.jcommander.ParameterException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import se.tfiskgul.mux2fs.CommandLineArguments.Strict;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.nio.file.FileSystem;
import java.nio.file.Path; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs;
@SuppressFBWarnings({ "DMI_HARDCODED_ABSOLUTE_FILENAME", "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" })
public class ParseCommandLineTest extends Fixture {
@Rule
public ExpectedException exception = ExpectedException.none();
private FileSystem fileSystem;
private CommandLineArguments commandLineArguments;
private Path root;
private Path tmp;
@Before
public void before() {
fileSystem = mockFileSystem();
root = mockPath("/", fileSystem);
tmp = mockDir(root, "tmp");
commandLineArguments = new CommandLineArguments(fileSystem);
}
@Test
public void testNoParametersParseFails() {
exception.expect(ParameterException.class);
commandLineArguments.parse(array());
}
@Test
public void testParseMandatory() {
Path target = mockDir(tmp, "target");
Path source = mockDir(tmp, "source");
Path tmpDir = mockDir(tmp, "dir"); | // Path: core/src/main/java/se/tfiskgul/mux2fs/CommandLineArguments.java
// public static class Strict extends Shared {
//
// @Parameter(names = "--tempdir", description = "Temporary directory under which to mux files", required = true)
// private Path tempDir;
// @Parameter(names = "-o", description = "Options", required = false)
// private List<String> options;
// private ImmutableList<String> passThroughOptions;
// private ImmutableList<String> fuseOptions;
//
// public Path getTempDir() {
// return tempDir;
// }
//
// public void validate() {
// validateDirectoryExists(getSource());
// validateDirectoryExists(getTarget());
// File tmpDirfile = tempDir.toFile();
// if (!tmpDirfile.exists()) {
// boolean mkdirs = tmpDirfile.mkdirs();
// if (!mkdirs) {
// logger.warn("Unable to automatically create directory {}", tempDir);
// }
// }
// validateDirectoryExists(tempDir);
// }
//
// @VisibleForTesting
// List<String> getPassThroughOptions() {
// return passThroughOptions;
// }
//
// public List<String> getFuseOptions() {
// return fuseOptions;
// }
// }
// Path: core/src/test/java/se/tfiskgul/mux2fs/ParseCommandLineTest.java
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import com.beust.jcommander.ParameterException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import se.tfiskgul.mux2fs.CommandLineArguments.Strict;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.nio.file.FileSystem;
import java.nio.file.Path;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs;
@SuppressFBWarnings({ "DMI_HARDCODED_ABSOLUTE_FILENAME", "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" })
public class ParseCommandLineTest extends Fixture {
@Rule
public ExpectedException exception = ExpectedException.none();
private FileSystem fileSystem;
private CommandLineArguments commandLineArguments;
private Path root;
private Path tmp;
@Before
public void before() {
fileSystem = mockFileSystem();
root = mockPath("/", fileSystem);
tmp = mockDir(root, "tmp");
commandLineArguments = new CommandLineArguments(fileSystem);
}
@Test
public void testNoParametersParseFails() {
exception.expect(ParameterException.class);
commandLineArguments.parse(array());
}
@Test
public void testParseMandatory() {
Path target = mockDir(tmp, "target");
Path source = mockDir(tmp, "source");
Path tmpDir = mockDir(tmp, "dir"); | Strict result = commandLineArguments.parse(array("--target", "/tmp/target", "--source", "/tmp/source", "--tempdir", "/tmp/dir")); |
tfiskgul/mux2fs | core/src/main/java/se/tfiskgul/mux2fs/fs/jnrfuse/FileSystemSafetyWrapper.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int BUG = -ErrorCodes.ENOSYS();
| import jnr.ffi.Pointer;
import jnr.ffi.types.off_t;
import jnr.ffi.types.size_t;
import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.FuseStubFS;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import static se.tfiskgul.mux2fs.Constants.BUG;
import java.nio.file.Path;
import java.util.function.Supplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | @Override
public int open(String path, FuseFileInfo fi) {
return wrap(() -> delegate.open(path, fi));
}
@Override
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
return wrap(() -> delegate.read(path, buf, size, offset, fi));
}
@Override
public int release(String path, FuseFileInfo fi) {
return wrap(() -> delegate.release(path, fi));
}
@Override
public void umount() {
super.umount();
}
@Override
public void destroy(Pointer initResult) {
wrap(() -> delegate.destroy(initResult));
}
private int wrap(Supplier<Integer> supplier) {
try {
return supplier.get();
} catch (Throwable e) {
logger.error("BUG: Uncaught exception!", e); | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int BUG = -ErrorCodes.ENOSYS();
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/jnrfuse/FileSystemSafetyWrapper.java
import jnr.ffi.Pointer;
import jnr.ffi.types.off_t;
import jnr.ffi.types.size_t;
import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.FuseStubFS;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import static se.tfiskgul.mux2fs.Constants.BUG;
import java.nio.file.Path;
import java.util.function.Supplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public int open(String path, FuseFileInfo fi) {
return wrap(() -> delegate.open(path, fi));
}
@Override
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
return wrap(() -> delegate.read(path, buf, size, offset, fi));
}
@Override
public int release(String path, FuseFileInfo fi) {
return wrap(() -> delegate.release(path, fi));
}
@Override
public void umount() {
super.umount();
}
@Override
public void destroy(Pointer initResult) {
wrap(() -> delegate.destroy(initResult));
}
private int wrap(Supplier<Integer> supplier) {
try {
return supplier.get();
} catch (Throwable e) {
logger.error("BUG: Uncaught exception!", e); | return BUG; |
tfiskgul/mux2fs | core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.fs.mirror;
public class MirrorFsTest extends MirrorFsFixture {
@Test
public void testGetAttr()
throws Exception {
// Given | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
// Path: core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.fs.mirror;
public class MirrorFsTest extends MirrorFsFixture {
@Test
public void testGetAttr()
throws Exception {
// Given | StatFiller stat = mock(StatFiller.class); |
tfiskgul/mux2fs | core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller; | /*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.fs.mirror;
public class MirrorFsTest extends MirrorFsFixture {
@Test
public void testGetAttr()
throws Exception {
// Given
StatFiller stat = mock(StatFiller.class);
when(fileSystem.getPath(mirrorRoot.toString(), "/")).thenReturn(mirrorRoot);
// When
int result = fs.getattr("/", stat);
// Then | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
// Path: core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller;
/*
MIT License
Copyright (c) 2017 Carl-Frederik Hallberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package se.tfiskgul.mux2fs.fs.mirror;
public class MirrorFsTest extends MirrorFsFixture {
@Test
public void testGetAttr()
throws Exception {
// Given
StatFiller stat = mock(StatFiller.class);
when(fileSystem.getPath(mirrorRoot.toString(), "/")).thenReturn(mirrorRoot);
// When
int result = fs.getattr("/", stat);
// Then | assertThat(result).isEqualTo(SUCCESS); |
tfiskgul/mux2fs | core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller; | // Then
assertThat(result).isEqualTo(SUCCESS);
verify(stat).stat(foo);
}
@Test
public void testAllErrorsForGetAttr()
throws Exception {
testAllErrors(this::getAttr);
}
private void getAttr(ExpectedResult expected)
throws Exception {
// Given
StatFiller stat = mock(StatFiller.class);
Path foo = mockPath("/foo");
when(stat.stat(foo)).thenThrow(expected.exception());
// When
int result = fs.getattr("/foo", stat);
// Then
assertThat(result).isEqualTo(expected.value());
}
@Test
public void testReadDir()
throws Exception {
// Given
Path foo = mockPath("foo");
Path bar = mockPath("bar");
mockDirectoryStream(mirrorRoot, foo, bar); | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
// Path: core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller;
// Then
assertThat(result).isEqualTo(SUCCESS);
verify(stat).stat(foo);
}
@Test
public void testAllErrorsForGetAttr()
throws Exception {
testAllErrors(this::getAttr);
}
private void getAttr(ExpectedResult expected)
throws Exception {
// Given
StatFiller stat = mock(StatFiller.class);
Path foo = mockPath("/foo");
when(stat.stat(foo)).thenThrow(expected.exception());
// When
int result = fs.getattr("/foo", stat);
// Then
assertThat(result).isEqualTo(expected.value());
}
@Test
public void testReadDir()
throws Exception {
// Given
Path foo = mockPath("foo");
Path bar = mockPath("bar");
mockDirectoryStream(mirrorRoot, foo, bar); | DirectoryFiller filler = mock(DirectoryFiller.class); |
tfiskgul/mux2fs | core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller; | mockDirectoryStream(mirrorRoot, foo, bar);
DirectoryFiller filler = mock(DirectoryFiller.class);
when(filler.add("foo", foo)).thenThrow(new IOException());
// When
int result = fs.readdir("/", filler);
// Then
assertThat(result).isEqualTo(SUCCESS);
verify(fileSystem.provider()).newDirectoryStream(eq(mirrorRoot), any());
verify(filler).add(".", mirrorRoot);
verify(filler).add("..", mirrorRoot);
verify(filler).add("foo", foo);
verify(filler).add("bar", bar);
verifyNoMoreInteractions(filler);
}
private void readDir(ExpectedResult expected)
throws IOException {
// Given
when(fileSystem.provider().newDirectoryStream(eq(mirrorRoot), any())).thenThrow(expected.exception());
DirectoryFiller filler = mock(DirectoryFiller.class);
// When
int result = fs.readdir("/", filler);
// Then
assertThat(result).isEqualTo(expected.value());
}
@Test
public void testOpen()
throws Exception {
// Given | // Path: core/src/main/java/se/tfiskgul/mux2fs/Constants.java
// public static final int SUCCESS = 0;
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/DirectoryFiller.java
// public interface DirectoryFiller {
//
// int add(String name, Path path)
// throws IOException;
//
// int addWithExtraSize(String name, Path path, long extraSize)
// throws IOException;
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/FileHandleFiller.java
// @FunctionalInterface
// public interface FileHandleFiller {
//
// void setFileHandle(int fileHandle);
//
// public static class Recorder implements FileHandleFiller {
//
// private final FileHandleFiller delegate;
// private int fileHandle = -1;
//
// public static Recorder wrap(FileHandleFiller filler) {
// return new Recorder(filler);
// }
//
// private Recorder(FileHandleFiller filler) {
// this.delegate = filler;
// }
//
// public int getFileHandle() {
// return fileHandle;
// }
//
// @Override
// public void setFileHandle(int fileHandle) {
// this.fileHandle = fileHandle;
// delegate.setFileHandle(fileHandle);
// }
// }
// }
//
// Path: core/src/main/java/se/tfiskgul/mux2fs/fs/base/StatFiller.java
// public interface StatFiller {
//
// UnixFileStat stat(Path path)
// throws IOException;
//
// UnixFileStat statWithSize(Path path, Function<FileInfo, Optional<Long>> sizeGetter, Supplier<Long> extraSizeGetter)
// throws IOException;
// }
// Path: core/src/test/java/se/tfiskgul/mux2fs/fs/mirror/MirrorFsTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalMatchers.gt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static se.tfiskgul.mux2fs.Constants.SUCCESS;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import ru.serce.jnrfuse.ErrorCodes;
import se.tfiskgul.mux2fs.fs.base.DirectoryFiller;
import se.tfiskgul.mux2fs.fs.base.FileHandleFiller;
import se.tfiskgul.mux2fs.fs.base.StatFiller;
mockDirectoryStream(mirrorRoot, foo, bar);
DirectoryFiller filler = mock(DirectoryFiller.class);
when(filler.add("foo", foo)).thenThrow(new IOException());
// When
int result = fs.readdir("/", filler);
// Then
assertThat(result).isEqualTo(SUCCESS);
verify(fileSystem.provider()).newDirectoryStream(eq(mirrorRoot), any());
verify(filler).add(".", mirrorRoot);
verify(filler).add("..", mirrorRoot);
verify(filler).add("foo", foo);
verify(filler).add("bar", bar);
verifyNoMoreInteractions(filler);
}
private void readDir(ExpectedResult expected)
throws IOException {
// Given
when(fileSystem.provider().newDirectoryStream(eq(mirrorRoot), any())).thenThrow(expected.exception());
DirectoryFiller filler = mock(DirectoryFiller.class);
// When
int result = fs.readdir("/", filler);
// Then
assertThat(result).isEqualTo(expected.value());
}
@Test
public void testOpen()
throws Exception {
// Given | FileHandleFiller filler = mock(FileHandleFiller.class); |
lmartire/DoApp | app/src/main/java/it/unisannio/security/DoApp/activities/EndActivity.java | // Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
| import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import it.unisannio.security.DoApp.R;
import it.unisannio.security.DoApp.model.Commons; | package it.unisannio.security.DoApp.activities;
public class EndActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_end);
Button button;
final String pathFile;
final TextView textView;
textView = (TextView) findViewById(R.id.textViewVisit);
button = (Button) findViewById(R.id.buttonEnd);
Intent i = getIntent(); | // Path: app/src/main/java/it/unisannio/security/DoApp/model/Commons.java
// public class Commons {
//
// // public static int ABOUT = 3;
//
// // sono i tre stadi per il progressbar di applistactivity
// public static final int MSG_PROCESSING = 0;
// public static final int MSG_DONE = 1;
// public static final int MSG_ERROR = 2;
//
// public static final int ACTIVITIES = 0;
// public static final int RECEIVERS = 1;
// public static final int SERVICES = 2;
//
// public static final String PKGINFO_KEY = "pkginfo";
// public static final String APPTYPE_KEY = "apptype";
// public static final String pkgName = "pkgname";
//
// public static final String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DoAppReports/";
// public static final String pathFile = "pathFile";
//
// }
// Path: app/src/main/java/it/unisannio/security/DoApp/activities/EndActivity.java
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import it.unisannio.security.DoApp.R;
import it.unisannio.security.DoApp.model.Commons;
package it.unisannio.security.DoApp.activities;
public class EndActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_end);
Button button;
final String pathFile;
final TextView textView;
textView = (TextView) findViewById(R.id.textViewVisit);
button = (Button) findViewById(R.id.buttonEnd);
Intent i = getIntent(); | pathFile = i.getStringExtra(Commons.pathFile); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.