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
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/TrainMessageAsyncModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java // @Service // @Scope("prototype") // public class ZugmonitorMessageSource extends MessageSource<String> { // // @Autowired // @Qualifier("zugmonitorMessageLoader") // private IMessageLoader<String> messageLoader; // // @Override // public IMessageLoader<String> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.train.message.ZugmonitorMessageSource;
package com.senacor.wicket.async.christmas.widgets.train; @Configurable public class TrainMessageAsyncModel extends AbstractAsyncModel<String> { @Autowired private transient ZugmonitorMessageSource messageSource; @Override
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java // @Service // @Scope("prototype") // public class ZugmonitorMessageSource extends MessageSource<String> { // // @Autowired // @Qualifier("zugmonitorMessageLoader") // private IMessageLoader<String> messageLoader; // // @Override // public IMessageLoader<String> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/TrainMessageAsyncModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.train.message.ZugmonitorMessageSource; package com.senacor.wicket.async.christmas.widgets.train; @Configurable public class TrainMessageAsyncModel extends AbstractAsyncModel<String> { @Autowired private transient ZugmonitorMessageSource messageSource; @Override
public IMessageSource<String> getMessageSource() {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
package com.senacor.wicket.async.christmas.app.websocket; /** * Prüft, ob Komponenten fertig geladen wurden und fügt sie in die Map ein, auf * der Updates gemacht werden * * @author Olaf Siefart, Senacor Technologies AG */ public class SendRefreshMessageRunnable extends WebsocketRunnable { public static final String REFRESH_MESSAGE = "refresh"; private final List<Component> refreshableComponents; private final AtomicBoolean finishThread; public SendRefreshMessageRunnable(ThreadContext threadContext, List<Component> refreshableComponents, AtomicBoolean finishThread, Integer messagePageId, String messageSessionId) { super(threadContext, messagePageId, messageSessionId); this.refreshableComponents = refreshableComponents; this.finishThread = finishThread; } @Override public void run() { while (!finishThread.get()) { boolean refreshNeeded = false; for (Component component : refreshableComponents) {
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; package com.senacor.wicket.async.christmas.app.websocket; /** * Prüft, ob Komponenten fertig geladen wurden und fügt sie in die Map ein, auf * der Updates gemacht werden * * @author Olaf Siefart, Senacor Technologies AG */ public class SendRefreshMessageRunnable extends WebsocketRunnable { public static final String REFRESH_MESSAGE = "refresh"; private final List<Component> refreshableComponents; private final AtomicBoolean finishThread; public SendRefreshMessageRunnable(ThreadContext threadContext, List<Component> refreshableComponents, AtomicBoolean finishThread, Integer messagePageId, String messageSessionId) { super(threadContext, messagePageId, messageSessionId); this.refreshableComponents = refreshableComponents; this.finishThread = finishThread; } @Override public void run() { while (!finishThread.get()) { boolean refreshNeeded = false; for (Component component : refreshableComponents) {
IAsyncModel<?> model = (IAsyncModel<?>) component.getDefaultModel();
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; import com.sun.syndication.feed.synd.SyndFeed;
package com.senacor.wicket.async.christmas.widgets.dilbert.message; @Service @Scope(value = "prototype")
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; import com.sun.syndication.feed.synd.SyndFeed; package com.senacor.wicket.async.christmas.widgets.dilbert.message; @Service @Scope(value = "prototype")
public class DilbertMessageSource extends MessageSource<SyndFeed> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; import com.sun.syndication.feed.synd.SyndFeed;
package com.senacor.wicket.async.christmas.widgets.dilbert.message; @Service @Scope(value = "prototype") public class DilbertMessageSource extends MessageSource<SyndFeed> { @Autowired @Qualifier("dilbertMessageLoader")
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; import com.sun.syndication.feed.synd.SyndFeed; package com.senacor.wicket.async.christmas.widgets.dilbert.message; @Service @Scope(value = "prototype") public class DilbertMessageSource extends MessageSource<SyndFeed> { @Autowired @Qualifier("dilbertMessageLoader")
private IMessageLoader<SyndFeed> messageLoader;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/core/heartbeat/HeartBeatConsumerBehavior.java
// Path: src/main/java/com/senacor/wicket/async/christmas/core/indicator/LoadingIndicatorPanel.java // public class LoadingIndicatorPanel extends Panel { // // /** // * Konstruktor. // * // * @param id // * die wicket id // */ // public LoadingIndicatorPanel(String id) { // super(id); // add(new Image("indicator", AbstractDefaultAjaxBehavior.INDICATOR)); // setOutputMarkupId(true); // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import org.apache.wicket.Component; import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.behavior.Behavior; import org.apache.wicket.event.IEvent; import com.senacor.wicket.async.christmas.core.indicator.LoadingIndicatorPanel; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
super.onEvent(component, event); if (event.getPayload() instanceof HeartBeatEvent) { HeartBeatEvent heartBeatEvent = (HeartBeatEvent) event.getPayload(); if (!isSpinningNeeded()) { controllingComponent.replaceWith(contentComponent); heartBeatEvent.getTarget().add(contentComponent); done(); } else { heartBeatEvent.getHeartBeatEventSource().continueBeating(); } } } /** * Called when the spinner is removed. */ protected void done() { } private Boolean isSpinningNeeded() { for (IAsyncModel<?> model : models) { if (model.isLoading()) { return Boolean.TRUE; } } return Boolean.FALSE; } protected Component newSpinner(String id) {
// Path: src/main/java/com/senacor/wicket/async/christmas/core/indicator/LoadingIndicatorPanel.java // public class LoadingIndicatorPanel extends Panel { // // /** // * Konstruktor. // * // * @param id // * die wicket id // */ // public LoadingIndicatorPanel(String id) { // super(id); // add(new Image("indicator", AbstractDefaultAjaxBehavior.INDICATOR)); // setOutputMarkupId(true); // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/core/heartbeat/HeartBeatConsumerBehavior.java import org.apache.wicket.Component; import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.behavior.Behavior; import org.apache.wicket.event.IEvent; import com.senacor.wicket.async.christmas.core.indicator.LoadingIndicatorPanel; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; super.onEvent(component, event); if (event.getPayload() instanceof HeartBeatEvent) { HeartBeatEvent heartBeatEvent = (HeartBeatEvent) event.getPayload(); if (!isSpinningNeeded()) { controllingComponent.replaceWith(contentComponent); heartBeatEvent.getTarget().add(contentComponent); done(); } else { heartBeatEvent.getHeartBeatEventSource().continueBeating(); } } } /** * Called when the spinner is removed. */ protected void done() { } private Boolean isSpinningNeeded() { for (IAsyncModel<?> model : models) { if (model.isLoading()) { return Boolean.TRUE; } } return Boolean.FALSE; } protected Component newSpinner(String id) {
return new LoadingIndicatorPanel(id);
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageLoaderMock.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // }
import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.Future; import org.springframework.context.annotation.Scope; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.delay.Delay; import com.senacor.wicket.async.christmas.core.runtime.profile.Dev; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader;
package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service("twitterMessageLoader") @Scope(value = "prototype") @Dev
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageLoaderMock.java import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.Future; import org.springframework.context.annotation.Scope; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.delay.Delay; import com.senacor.wicket.async.christmas.core.runtime.profile.Dev; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service("twitterMessageLoader") @Scope(value = "prototype") @Dev
public class TwitterMessageLoaderMock implements IMessageLoader<Tweet> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/source/NetworkStringSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/IStringSource.java // public interface IStringSource { // String getCitiesAndStations(); // // String getTrains(DateTime date); // }
import java.io.StringWriter; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.joda.time.DateTime; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; import com.senacor.wicket.async.christmas.core.runtime.profile.Prod; import com.senacor.wicket.async.christmas.widgets.train.message.IStringSource;
package com.senacor.wicket.async.christmas.widgets.train.message.source; /** * @author Jochen Mader */ @Repository @Scope("prototype") @Prod
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/IStringSource.java // public interface IStringSource { // String getCitiesAndStations(); // // String getTrains(DateTime date); // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/source/NetworkStringSource.java import java.io.StringWriter; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.joda.time.DateTime; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; import com.senacor.wicket.async.christmas.core.runtime.profile.Prod; import com.senacor.wicket.async.christmas.widgets.train.message.IStringSource; package com.senacor.wicket.async.christmas.widgets.train.message.source; /** * @author Jochen Mader */ @Repository @Scope("prototype") @Prod
public class NetworkStringSource implements IStringSource {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageLoaderMock.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // }
import java.util.List; import java.util.concurrent.Future; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.delay.Delay; import com.senacor.wicket.async.christmas.core.runtime.profile.Dev; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.sun.syndication.feed.synd.SyndContentImpl; import com.sun.syndication.feed.synd.SyndEntryImpl; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.feed.synd.SyndFeedImpl;
package com.senacor.wicket.async.christmas.widgets.dilbert.message; /** * * @author Olaf Siefart, Senacor Technologies AG */ @Service("dilbertMessageLoader") @Dev
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageLoaderMock.java import java.util.List; import java.util.concurrent.Future; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.delay.Delay; import com.senacor.wicket.async.christmas.core.runtime.profile.Dev; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.sun.syndication.feed.synd.SyndContentImpl; import com.sun.syndication.feed.synd.SyndEntryImpl; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.feed.synd.SyndFeedImpl; package com.senacor.wicket.async.christmas.widgets.dilbert.message; /** * * @author Olaf Siefart, Senacor Technologies AG */ @Service("dilbertMessageLoader") @Dev
public class DilbertMessageLoaderMock implements IMessageLoader<SyndFeed> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource;
package com.senacor.wicket.async.christmas.widgets.train.message; /** * @author Jochen Mader */ @Service @Scope("prototype")
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; package com.senacor.wicket.async.christmas.widgets.train.message; /** * @author Jochen Mader */ @Service @Scope("prototype")
public class ZugmonitorMessageSource extends MessageSource<String> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource;
package com.senacor.wicket.async.christmas.widgets.train.message; /** * @author Jochen Mader */ @Service @Scope("prototype") public class ZugmonitorMessageSource extends MessageSource<String> { @Autowired @Qualifier("zugmonitorMessageLoader")
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; package com.senacor.wicket.async.christmas.widgets.train.message; /** * @author Jochen Mader */ @Service @Scope("prototype") public class ZugmonitorMessageSource extends MessageSource<String> { @Autowired @Qualifier("zugmonitorMessageLoader")
private IMessageLoader<String> messageLoader;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertAsyncModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed;
package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertAsyncModel extends AbstractAsyncModel<SyndFeed> { @Autowired
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertAsyncModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed; package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertAsyncModel extends AbstractAsyncModel<SyndFeed> { @Autowired
private transient DilbertMessageSource messageSource;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertAsyncModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed;
package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertAsyncModel extends AbstractAsyncModel<SyndFeed> { @Autowired private transient DilbertMessageSource messageSource; @Override
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertAsyncModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed; package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertAsyncModel extends AbstractAsyncModel<SyndFeed> { @Autowired private transient DilbertMessageSource messageSource; @Override
public IMessageSource<SyndFeed> getMessageSource() {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageAsyncModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource;
package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageAsyncModel extends AbstractAsyncModel<Tweet> { @Autowired
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageAsyncModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource; package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageAsyncModel extends AbstractAsyncModel<Tweet> { @Autowired
private transient TwitterMessageSource messageSource;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageAsyncModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource;
package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageAsyncModel extends AbstractAsyncModel<Tweet> { @Autowired private transient TwitterMessageSource messageSource; @Override
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java // public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // private transient T lastMessage = null; // // @Override // public T getObject() { // T ret = getMessageSource().getMessage(); // if (ret == null) { // getMessageSource().loadNext(); // ret = lastMessage; // } else { // lastMessage = ret; // } // return ret; // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // public abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageAsyncModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractAsyncModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource; package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageAsyncModel extends AbstractAsyncModel<Tweet> { @Autowired private transient TwitterMessageSource messageSource; @Override
public IMessageSource<Tweet> getMessageSource() {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/TrainMessageBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java // @Service // @Scope("prototype") // public class ZugmonitorMessageSource extends MessageSource<String> { // // @Autowired // @Qualifier("zugmonitorMessageLoader") // private IMessageLoader<String> messageLoader; // // @Override // public IMessageLoader<String> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.train.message.ZugmonitorMessageSource;
package com.senacor.wicket.async.christmas.widgets.train; @Configurable public class TrainMessageBlockingModel extends AbstractBlockingModel<String> { @Autowired
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java // @Service // @Scope("prototype") // public class ZugmonitorMessageSource extends MessageSource<String> { // // @Autowired // @Qualifier("zugmonitorMessageLoader") // private IMessageLoader<String> messageLoader; // // @Override // public IMessageLoader<String> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/TrainMessageBlockingModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.train.message.ZugmonitorMessageSource; package com.senacor.wicket.async.christmas.widgets.train; @Configurable public class TrainMessageBlockingModel extends AbstractBlockingModel<String> { @Autowired
private transient ZugmonitorMessageSource messageSource;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/TrainMessageBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java // @Service // @Scope("prototype") // public class ZugmonitorMessageSource extends MessageSource<String> { // // @Autowired // @Qualifier("zugmonitorMessageLoader") // private IMessageLoader<String> messageLoader; // // @Override // public IMessageLoader<String> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.train.message.ZugmonitorMessageSource;
package com.senacor.wicket.async.christmas.widgets.train; @Configurable public class TrainMessageBlockingModel extends AbstractBlockingModel<String> { @Autowired private transient ZugmonitorMessageSource messageSource; @Override
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/ZugmonitorMessageSource.java // @Service // @Scope("prototype") // public class ZugmonitorMessageSource extends MessageSource<String> { // // @Autowired // @Qualifier("zugmonitorMessageLoader") // private IMessageLoader<String> messageLoader; // // @Override // public IMessageLoader<String> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/TrainMessageBlockingModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.train.message.ZugmonitorMessageSource; package com.senacor.wicket.async.christmas.widgets.train; @Configurable public class TrainMessageBlockingModel extends AbstractBlockingModel<String> { @Autowired private transient ZugmonitorMessageSource messageSource; @Override
protected IMessageSource<String> getMessageSource() {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource;
package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service @Qualifier("twitterMessageSource") @Scope(value = "prototype")
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service @Qualifier("twitterMessageSource") @Scope(value = "prototype")
public class TwitterMessageSource extends MessageSource<Tweet> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource;
package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service @Qualifier("twitterMessageSource") @Scope(value = "prototype") public class TwitterMessageSource extends MessageSource<Tweet> { @Autowired @Qualifier("twitterMessageLoader")
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/MessageSource.java // public abstract class MessageSource<T> implements IMessageSource<T> { // // private final LinkedBlockingQueue<T> messageQueue = new LinkedBlockingQueue<T>(); // private final AtomicBoolean loading = new AtomicBoolean(); // private Future<List<T>> future = null; // // public abstract IMessageLoader<T> getMessageLoader(); // // @Override // public T getMessage() { // if (messageQueue.peek() == null) { // checkIfFutureIsDoneWithoutBlocking(); // } // return messageQueue.poll(); // } // // @Override // public T getMessageSync() { // if (messageQueue.peek() == null) { // loadNext(); // fillQueueFromFutureBlocking(); // } // return messageQueue.poll(); // } // // private void checkIfFutureIsDoneWithoutBlocking() { // if ((future != null) && future.isDone()) { // fillQueueFromFutureBlocking(); // } // } // // private void fillQueueFromFutureBlocking() { // try { // for (T status : future.get()) { // messageQueue.put(status); // } // } catch (InterruptedException e) { // Thread.currentThread().interrupt(); // } catch (ExecutionException e) { // throw new RuntimeException(e); // } finally { // future = null; // loading.set(Boolean.FALSE); // } // } // // @Override // public Boolean hasNext() { // return !messageQueue.isEmpty(); // } // // @Override // public void loadNext() { // if (messageQueue.isEmpty() && loading.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { // future = getMessageLoader().load(); // } // } // // @Override // public Boolean isLoading() { // checkIfFutureIsDoneWithoutBlocking(); // return loading.get(); // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.senacor.wicket.async.christmas.widgets.api.message.MessageSource; package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service @Qualifier("twitterMessageSource") @Scope(value = "prototype") public class TwitterMessageSource extends MessageSource<Tweet> { @Autowired @Qualifier("twitterMessageLoader")
private IMessageLoader<Tweet> messageLoader;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import java.util.Iterator; import java.util.Map; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
package com.senacor.wicket.async.christmas.app.websocket; /** * Prüft, ob Komponenten fertig geladen wurden und fügt sie in die Map ein, auf * der Updates gemacht werden * * @author Olaf Siefart, Senacor Technologies AG */ public class SendUpdateMessageRunnable extends WebsocketRunnable { public static final String UPDATE_MESSAGE = "update"; private final Map<Component, Component> updateNeededComponents; private final Map<Component, Component> asyncLoadingComponents; public SendUpdateMessageRunnable(ThreadContext threadContext, Map<Component, Component> asyncLoadingComponents, Map<Component, Component> updateNeededComponents, Integer messagePageId, String messageSessionId) { super(threadContext, messagePageId, messageSessionId); this.asyncLoadingComponents = asyncLoadingComponents; this.updateNeededComponents = updateNeededComponents; } @Override public void run() { while (!asyncLoadingComponents.isEmpty()) { for (Iterator<Map.Entry<Component, Component>> iterator = asyncLoadingComponents.entrySet().iterator(); iterator.hasNext();) { Map.Entry<Component, Component> entry = iterator.next();
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java import java.util.Iterator; import java.util.Map; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; package com.senacor.wicket.async.christmas.app.websocket; /** * Prüft, ob Komponenten fertig geladen wurden und fügt sie in die Map ein, auf * der Updates gemacht werden * * @author Olaf Siefart, Senacor Technologies AG */ public class SendUpdateMessageRunnable extends WebsocketRunnable { public static final String UPDATE_MESSAGE = "update"; private final Map<Component, Component> updateNeededComponents; private final Map<Component, Component> asyncLoadingComponents; public SendUpdateMessageRunnable(ThreadContext threadContext, Map<Component, Component> asyncLoadingComponents, Map<Component, Component> updateNeededComponents, Integer messagePageId, String messageSessionId) { super(threadContext, messagePageId, messageSessionId); this.asyncLoadingComponents = asyncLoadingComponents; this.updateNeededComponents = updateNeededComponents; } @Override public void run() { while (!asyncLoadingComponents.isEmpty()) { for (Iterator<Map.Entry<Component, Component>> iterator = asyncLoadingComponents.entrySet().iterator(); iterator.hasNext();) { Map.Entry<Component, Component> entry = iterator.next();
IAsyncModel<?> model = (IAsyncModel<?>) entry.getKey().getDefaultModel();
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource;
package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageBlockingModel extends AbstractBlockingModel<Tweet> { @Autowired
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageBlockingModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource; package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageBlockingModel extends AbstractBlockingModel<Tweet> { @Autowired
private transient TwitterMessageSource messageSource;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource;
package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageBlockingModel extends AbstractBlockingModel<Tweet> { @Autowired private transient TwitterMessageSource messageSource; @Override
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageSource.java // @Service // @Qualifier("twitterMessageSource") // @Scope(value = "prototype") // public class TwitterMessageSource extends MessageSource<Tweet> { // // @Autowired // @Qualifier("twitterMessageLoader") // private IMessageLoader<Tweet> messageLoader; // // @Override // public IMessageLoader<Tweet> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/TwitterMessageBlockingModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.social.twitter.api.Tweet; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.twitter.message.TwitterMessageSource; package com.senacor.wicket.async.christmas.widgets.twitter; @Configurable public class TwitterMessageBlockingModel extends AbstractBlockingModel<Tweet> { @Autowired private transient TwitterMessageSource messageSource; @Override
protected IMessageSource<Tweet> getMessageSource() {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // }
import org.apache.wicket.model.AbstractReadOnlyModel; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource;
package com.senacor.wicket.async.christmas.widgets.api.model; /** * @author Jochen Mader */ public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { private transient T lastMessage = null; @Override public T getObject() { T ret = getMessageSource().getMessage(); if (ret == null) { getMessageSource().loadNext(); ret = lastMessage; } else { lastMessage = ret; } return ret; } @Override public Boolean isLoading() { return getMessageSource().isLoading(); } @Override public void startLoading() { getMessageSource().loadNext(); } @Override public Boolean hasNext() { return getMessageSource().hasNext(); }
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractAsyncModel.java import org.apache.wicket.model.AbstractReadOnlyModel; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; package com.senacor.wicket.async.christmas.widgets.api.model; /** * @author Jochen Mader */ public abstract class AbstractAsyncModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { private transient T lastMessage = null; @Override public T getObject() { T ret = getMessageSource().getMessage(); if (ret == null) { getMessageSource().loadNext(); ret = lastMessage; } else { lastMessage = ret; } return ret; } @Override public Boolean isLoading() { return getMessageSource().isLoading(); } @Override public void startLoading() { getMessageSource().loadNext(); } @Override public Boolean hasNext() { return getMessageSource().hasNext(); }
public abstract IMessageSource<T> getMessageSource();
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketRunnable.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java // public class ChristmasApplication extends WebApplication { // // @Override // public Class<? extends WebPage> getHomePage() { // return HomePage.class; // } // // @Override // public void init() { // super.init(); // // mountPage("lazyloading", LazyLoadingPage.class); // mountPage("websockets", WebsocketPage.class); // // getComponentInstantiationListeners().add(new SpringComponentInjector(this)); // getComponentInstantiationListeners().add(new LetItSnowComponentInstantiationListener()); // } // // public static ChristmasApplication get() { // return (ChristmasApplication) WebApplication.get(); // } // // }
import java.io.IOException; import org.apache.wicket.Application; import org.apache.wicket.ThreadContext; import org.apache.wicket.protocol.ws.api.IWebSocketConnection; import org.apache.wicket.protocol.ws.api.IWebSocketConnectionRegistry; import org.apache.wicket.protocol.ws.api.SimpleWebSocketConnectionRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.app.ChristmasApplication;
package com.senacor.wicket.async.christmas.app.websocket; /** * Websocket Runnable * * @author Olaf Siefart, Senacor Technologies AG */ public abstract class WebsocketRunnable implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(WebsocketRunnable.class); private final Integer messagePageId; private final String messageSessionId; private final ThreadContext threadContext; public WebsocketRunnable(ThreadContext threadContext, Integer messagePageId, String messageSessionId) { this.threadContext = threadContext; this.messagePageId = messagePageId; this.messageSessionId = messageSessionId; } protected void sleep(int timeout) { try { Thread.sleep(timeout); } catch (InterruptedException e) { e.printStackTrace(); } } protected void sendMessage(String message) { ThreadContext.restore(threadContext);
// Path: src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java // public class ChristmasApplication extends WebApplication { // // @Override // public Class<? extends WebPage> getHomePage() { // return HomePage.class; // } // // @Override // public void init() { // super.init(); // // mountPage("lazyloading", LazyLoadingPage.class); // mountPage("websockets", WebsocketPage.class); // // getComponentInstantiationListeners().add(new SpringComponentInjector(this)); // getComponentInstantiationListeners().add(new LetItSnowComponentInstantiationListener()); // } // // public static ChristmasApplication get() { // return (ChristmasApplication) WebApplication.get(); // } // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketRunnable.java import java.io.IOException; import org.apache.wicket.Application; import org.apache.wicket.ThreadContext; import org.apache.wicket.protocol.ws.api.IWebSocketConnection; import org.apache.wicket.protocol.ws.api.IWebSocketConnectionRegistry; import org.apache.wicket.protocol.ws.api.SimpleWebSocketConnectionRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.app.ChristmasApplication; package com.senacor.wicket.async.christmas.app.websocket; /** * Websocket Runnable * * @author Olaf Siefart, Senacor Technologies AG */ public abstract class WebsocketRunnable implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(WebsocketRunnable.class); private final Integer messagePageId; private final String messageSessionId; private final ThreadContext threadContext; public WebsocketRunnable(ThreadContext threadContext, Integer messagePageId, String messageSessionId) { this.threadContext = threadContext; this.messagePageId = messagePageId; this.messageSessionId = messageSessionId; } protected void sleep(int timeout) { try { Thread.sleep(timeout); } catch (InterruptedException e) { e.printStackTrace(); } } protected void sendMessage(String message) { ThreadContext.restore(threadContext);
final Application application = ChristmasApplication.get();
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageLoader.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // }
import java.util.List; import java.util.concurrent.Future; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.social.twitter.api.Tweet; import org.springframework.social.twitter.api.impl.TwitterTemplate; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.profile.Prod; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader;
package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service("twitterMessageLoader") @Scope(value = "prototype") @Prod
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/twitter/message/TwitterMessageLoader.java import java.util.List; import java.util.concurrent.Future; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.social.twitter.api.Tweet; import org.springframework.social.twitter.api.impl.TwitterTemplate; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.profile.Prod; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; package com.senacor.wicket.async.christmas.widgets.twitter.message; /** * A message factory linked to a Twitter account. This class MUST be used as a * session scoped object. * * @author Jochen Mader */ @Service("twitterMessageLoader") @Scope(value = "prototype") @Prod
public class TwitterMessageLoader implements IMessageLoader<Tweet> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/lazyloading/LazyLoadingPage.java // public class LazyLoadingPage extends WebPage { // // public LazyLoadingPage() { // // add(new PageRequestCounter("counter")); // // Panel trainInformationLazyLoadPanel = new AjaxLazyLoadPanel("trainInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TrainInformationPanel trainInformationPanel = new TrainInformationPanel(markupId, new TrainMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); // } // }; // return trainInformationPanel; // } // // }; // add(trainInformationLazyLoadPanel); // // Panel twitterInformationLazyLoadPanel = new AjaxLazyLoadPanel("twitterInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TwitterInformationPanel twitterInformationPanel = new TwitterInformationPanel(markupId, new TwitterMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15))); // } // }; // return twitterInformationPanel; // } // // }; // add(twitterInformationLazyLoadPanel); // // Panel dilbertInformationLazyLoadPanel = new AjaxLazyLoadPanel("dilbertInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // DilbertInformationPanel dilbertInformationPanel = new DilbertInformationPanel(markupId, new DilbertBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(45))); // } // }; // return dilbertInformationPanel; // } // // }; // add(dilbertInformationLazyLoadPanel); // // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketPage.java // public class WebsocketPage extends WebPage { // // private final ConcurrentHashMap<Component, Component> loadingComponents; // // public WebsocketPage() { // // loadingComponents = new ConcurrentHashMap<Component, Component>(); // // final PageRequestCounter pageRequestCounter = new PageRequestCounter("counter"); // add(pageRequestCounter); // // add(new UpdatingWebsocketBehavior(loadingComponents) { // @Override // protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { // super.onMessage(handler, message); // handler.add(pageRequestCounter); // } // }); // // // Train // Component trainLoadingIndicator = new LoadingIndicatorPanel("trainInformation"); // Component trainInformationPanel = new TrainInformationPanel("trainInformation", new TrainMessageAsyncModel()); // loadingComponents.put(trainInformationPanel, trainLoadingIndicator); // add(trainLoadingIndicator); // // // Twitter // Component twitterLoadingIndicator = new LoadingIndicatorPanel("twitterInformation"); // Component twitterInformationPanel = new TwitterInformationPanel("twitterInformation", new TwitterMessageAsyncModel()); // loadingComponents.put(twitterInformationPanel, twitterLoadingIndicator); // add(twitterLoadingIndicator); // // // Dilbert // Component dilbertLoadingIndicator = new LoadingIndicatorPanel("dilbertInformation"); // Component dilbertInformationPanel = new DilbertInformationPanel("dilbertInformation", new DilbertAsyncModel()); // loadingComponents.put(dilbertInformationPanel, dilbertLoadingIndicator); // add(dilbertLoadingIndicator); // // } // // @Override // protected void onConfigure() { // super.onConfigure(); // // // Das Laden in den einzelnen Komponenten anstoßen // for (Component asyncLoadingComponent : loadingComponents.keySet()) { // asyncLoadingComponent.getDefaultModel().getObject(); // } // // } // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/core/snow/LetItSnowComponentInstantiationListener.java // public class LetItSnowComponentInstantiationListener implements IComponentInstantiationListener { // // @Override // public void onInstantiation(Component component) { // if (component instanceof WebPage) { // component.add(new LetItSnowBehavior()); // } // } // // }
import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import com.senacor.wicket.async.christmas.app.lazyloading.LazyLoadingPage; import com.senacor.wicket.async.christmas.app.websocket.WebsocketPage; import com.senacor.wicket.async.christmas.core.snow.LetItSnowComponentInstantiationListener;
package com.senacor.wicket.async.christmas.app; public class ChristmasApplication extends WebApplication { @Override public Class<? extends WebPage> getHomePage() { return HomePage.class; } @Override public void init() { super.init();
// Path: src/main/java/com/senacor/wicket/async/christmas/app/lazyloading/LazyLoadingPage.java // public class LazyLoadingPage extends WebPage { // // public LazyLoadingPage() { // // add(new PageRequestCounter("counter")); // // Panel trainInformationLazyLoadPanel = new AjaxLazyLoadPanel("trainInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TrainInformationPanel trainInformationPanel = new TrainInformationPanel(markupId, new TrainMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); // } // }; // return trainInformationPanel; // } // // }; // add(trainInformationLazyLoadPanel); // // Panel twitterInformationLazyLoadPanel = new AjaxLazyLoadPanel("twitterInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TwitterInformationPanel twitterInformationPanel = new TwitterInformationPanel(markupId, new TwitterMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15))); // } // }; // return twitterInformationPanel; // } // // }; // add(twitterInformationLazyLoadPanel); // // Panel dilbertInformationLazyLoadPanel = new AjaxLazyLoadPanel("dilbertInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // DilbertInformationPanel dilbertInformationPanel = new DilbertInformationPanel(markupId, new DilbertBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(45))); // } // }; // return dilbertInformationPanel; // } // // }; // add(dilbertInformationLazyLoadPanel); // // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketPage.java // public class WebsocketPage extends WebPage { // // private final ConcurrentHashMap<Component, Component> loadingComponents; // // public WebsocketPage() { // // loadingComponents = new ConcurrentHashMap<Component, Component>(); // // final PageRequestCounter pageRequestCounter = new PageRequestCounter("counter"); // add(pageRequestCounter); // // add(new UpdatingWebsocketBehavior(loadingComponents) { // @Override // protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { // super.onMessage(handler, message); // handler.add(pageRequestCounter); // } // }); // // // Train // Component trainLoadingIndicator = new LoadingIndicatorPanel("trainInformation"); // Component trainInformationPanel = new TrainInformationPanel("trainInformation", new TrainMessageAsyncModel()); // loadingComponents.put(trainInformationPanel, trainLoadingIndicator); // add(trainLoadingIndicator); // // // Twitter // Component twitterLoadingIndicator = new LoadingIndicatorPanel("twitterInformation"); // Component twitterInformationPanel = new TwitterInformationPanel("twitterInformation", new TwitterMessageAsyncModel()); // loadingComponents.put(twitterInformationPanel, twitterLoadingIndicator); // add(twitterLoadingIndicator); // // // Dilbert // Component dilbertLoadingIndicator = new LoadingIndicatorPanel("dilbertInformation"); // Component dilbertInformationPanel = new DilbertInformationPanel("dilbertInformation", new DilbertAsyncModel()); // loadingComponents.put(dilbertInformationPanel, dilbertLoadingIndicator); // add(dilbertLoadingIndicator); // // } // // @Override // protected void onConfigure() { // super.onConfigure(); // // // Das Laden in den einzelnen Komponenten anstoßen // for (Component asyncLoadingComponent : loadingComponents.keySet()) { // asyncLoadingComponent.getDefaultModel().getObject(); // } // // } // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/core/snow/LetItSnowComponentInstantiationListener.java // public class LetItSnowComponentInstantiationListener implements IComponentInstantiationListener { // // @Override // public void onInstantiation(Component component) { // if (component instanceof WebPage) { // component.add(new LetItSnowBehavior()); // } // } // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import com.senacor.wicket.async.christmas.app.lazyloading.LazyLoadingPage; import com.senacor.wicket.async.christmas.app.websocket.WebsocketPage; import com.senacor.wicket.async.christmas.core.snow.LetItSnowComponentInstantiationListener; package com.senacor.wicket.async.christmas.app; public class ChristmasApplication extends WebApplication { @Override public Class<? extends WebPage> getHomePage() { return HomePage.class; } @Override public void init() { super.init();
mountPage("lazyloading", LazyLoadingPage.class);
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/lazyloading/LazyLoadingPage.java // public class LazyLoadingPage extends WebPage { // // public LazyLoadingPage() { // // add(new PageRequestCounter("counter")); // // Panel trainInformationLazyLoadPanel = new AjaxLazyLoadPanel("trainInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TrainInformationPanel trainInformationPanel = new TrainInformationPanel(markupId, new TrainMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); // } // }; // return trainInformationPanel; // } // // }; // add(trainInformationLazyLoadPanel); // // Panel twitterInformationLazyLoadPanel = new AjaxLazyLoadPanel("twitterInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TwitterInformationPanel twitterInformationPanel = new TwitterInformationPanel(markupId, new TwitterMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15))); // } // }; // return twitterInformationPanel; // } // // }; // add(twitterInformationLazyLoadPanel); // // Panel dilbertInformationLazyLoadPanel = new AjaxLazyLoadPanel("dilbertInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // DilbertInformationPanel dilbertInformationPanel = new DilbertInformationPanel(markupId, new DilbertBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(45))); // } // }; // return dilbertInformationPanel; // } // // }; // add(dilbertInformationLazyLoadPanel); // // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketPage.java // public class WebsocketPage extends WebPage { // // private final ConcurrentHashMap<Component, Component> loadingComponents; // // public WebsocketPage() { // // loadingComponents = new ConcurrentHashMap<Component, Component>(); // // final PageRequestCounter pageRequestCounter = new PageRequestCounter("counter"); // add(pageRequestCounter); // // add(new UpdatingWebsocketBehavior(loadingComponents) { // @Override // protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { // super.onMessage(handler, message); // handler.add(pageRequestCounter); // } // }); // // // Train // Component trainLoadingIndicator = new LoadingIndicatorPanel("trainInformation"); // Component trainInformationPanel = new TrainInformationPanel("trainInformation", new TrainMessageAsyncModel()); // loadingComponents.put(trainInformationPanel, trainLoadingIndicator); // add(trainLoadingIndicator); // // // Twitter // Component twitterLoadingIndicator = new LoadingIndicatorPanel("twitterInformation"); // Component twitterInformationPanel = new TwitterInformationPanel("twitterInformation", new TwitterMessageAsyncModel()); // loadingComponents.put(twitterInformationPanel, twitterLoadingIndicator); // add(twitterLoadingIndicator); // // // Dilbert // Component dilbertLoadingIndicator = new LoadingIndicatorPanel("dilbertInformation"); // Component dilbertInformationPanel = new DilbertInformationPanel("dilbertInformation", new DilbertAsyncModel()); // loadingComponents.put(dilbertInformationPanel, dilbertLoadingIndicator); // add(dilbertLoadingIndicator); // // } // // @Override // protected void onConfigure() { // super.onConfigure(); // // // Das Laden in den einzelnen Komponenten anstoßen // for (Component asyncLoadingComponent : loadingComponents.keySet()) { // asyncLoadingComponent.getDefaultModel().getObject(); // } // // } // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/core/snow/LetItSnowComponentInstantiationListener.java // public class LetItSnowComponentInstantiationListener implements IComponentInstantiationListener { // // @Override // public void onInstantiation(Component component) { // if (component instanceof WebPage) { // component.add(new LetItSnowBehavior()); // } // } // // }
import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import com.senacor.wicket.async.christmas.app.lazyloading.LazyLoadingPage; import com.senacor.wicket.async.christmas.app.websocket.WebsocketPage; import com.senacor.wicket.async.christmas.core.snow.LetItSnowComponentInstantiationListener;
package com.senacor.wicket.async.christmas.app; public class ChristmasApplication extends WebApplication { @Override public Class<? extends WebPage> getHomePage() { return HomePage.class; } @Override public void init() { super.init(); mountPage("lazyloading", LazyLoadingPage.class);
// Path: src/main/java/com/senacor/wicket/async/christmas/app/lazyloading/LazyLoadingPage.java // public class LazyLoadingPage extends WebPage { // // public LazyLoadingPage() { // // add(new PageRequestCounter("counter")); // // Panel trainInformationLazyLoadPanel = new AjaxLazyLoadPanel("trainInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TrainInformationPanel trainInformationPanel = new TrainInformationPanel(markupId, new TrainMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); // } // }; // return trainInformationPanel; // } // // }; // add(trainInformationLazyLoadPanel); // // Panel twitterInformationLazyLoadPanel = new AjaxLazyLoadPanel("twitterInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TwitterInformationPanel twitterInformationPanel = new TwitterInformationPanel(markupId, new TwitterMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15))); // } // }; // return twitterInformationPanel; // } // // }; // add(twitterInformationLazyLoadPanel); // // Panel dilbertInformationLazyLoadPanel = new AjaxLazyLoadPanel("dilbertInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // DilbertInformationPanel dilbertInformationPanel = new DilbertInformationPanel(markupId, new DilbertBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(45))); // } // }; // return dilbertInformationPanel; // } // // }; // add(dilbertInformationLazyLoadPanel); // // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketPage.java // public class WebsocketPage extends WebPage { // // private final ConcurrentHashMap<Component, Component> loadingComponents; // // public WebsocketPage() { // // loadingComponents = new ConcurrentHashMap<Component, Component>(); // // final PageRequestCounter pageRequestCounter = new PageRequestCounter("counter"); // add(pageRequestCounter); // // add(new UpdatingWebsocketBehavior(loadingComponents) { // @Override // protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { // super.onMessage(handler, message); // handler.add(pageRequestCounter); // } // }); // // // Train // Component trainLoadingIndicator = new LoadingIndicatorPanel("trainInformation"); // Component trainInformationPanel = new TrainInformationPanel("trainInformation", new TrainMessageAsyncModel()); // loadingComponents.put(trainInformationPanel, trainLoadingIndicator); // add(trainLoadingIndicator); // // // Twitter // Component twitterLoadingIndicator = new LoadingIndicatorPanel("twitterInformation"); // Component twitterInformationPanel = new TwitterInformationPanel("twitterInformation", new TwitterMessageAsyncModel()); // loadingComponents.put(twitterInformationPanel, twitterLoadingIndicator); // add(twitterLoadingIndicator); // // // Dilbert // Component dilbertLoadingIndicator = new LoadingIndicatorPanel("dilbertInformation"); // Component dilbertInformationPanel = new DilbertInformationPanel("dilbertInformation", new DilbertAsyncModel()); // loadingComponents.put(dilbertInformationPanel, dilbertLoadingIndicator); // add(dilbertLoadingIndicator); // // } // // @Override // protected void onConfigure() { // super.onConfigure(); // // // Das Laden in den einzelnen Komponenten anstoßen // for (Component asyncLoadingComponent : loadingComponents.keySet()) { // asyncLoadingComponent.getDefaultModel().getObject(); // } // // } // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/core/snow/LetItSnowComponentInstantiationListener.java // public class LetItSnowComponentInstantiationListener implements IComponentInstantiationListener { // // @Override // public void onInstantiation(Component component) { // if (component instanceof WebPage) { // component.add(new LetItSnowBehavior()); // } // } // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import com.senacor.wicket.async.christmas.app.lazyloading.LazyLoadingPage; import com.senacor.wicket.async.christmas.app.websocket.WebsocketPage; import com.senacor.wicket.async.christmas.core.snow.LetItSnowComponentInstantiationListener; package com.senacor.wicket.async.christmas.app; public class ChristmasApplication extends WebApplication { @Override public Class<? extends WebPage> getHomePage() { return HomePage.class; } @Override public void init() { super.init(); mountPage("lazyloading", LazyLoadingPage.class);
mountPage("websockets", WebsocketPage.class);
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/lazyloading/LazyLoadingPage.java // public class LazyLoadingPage extends WebPage { // // public LazyLoadingPage() { // // add(new PageRequestCounter("counter")); // // Panel trainInformationLazyLoadPanel = new AjaxLazyLoadPanel("trainInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TrainInformationPanel trainInformationPanel = new TrainInformationPanel(markupId, new TrainMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); // } // }; // return trainInformationPanel; // } // // }; // add(trainInformationLazyLoadPanel); // // Panel twitterInformationLazyLoadPanel = new AjaxLazyLoadPanel("twitterInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TwitterInformationPanel twitterInformationPanel = new TwitterInformationPanel(markupId, new TwitterMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15))); // } // }; // return twitterInformationPanel; // } // // }; // add(twitterInformationLazyLoadPanel); // // Panel dilbertInformationLazyLoadPanel = new AjaxLazyLoadPanel("dilbertInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // DilbertInformationPanel dilbertInformationPanel = new DilbertInformationPanel(markupId, new DilbertBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(45))); // } // }; // return dilbertInformationPanel; // } // // }; // add(dilbertInformationLazyLoadPanel); // // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketPage.java // public class WebsocketPage extends WebPage { // // private final ConcurrentHashMap<Component, Component> loadingComponents; // // public WebsocketPage() { // // loadingComponents = new ConcurrentHashMap<Component, Component>(); // // final PageRequestCounter pageRequestCounter = new PageRequestCounter("counter"); // add(pageRequestCounter); // // add(new UpdatingWebsocketBehavior(loadingComponents) { // @Override // protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { // super.onMessage(handler, message); // handler.add(pageRequestCounter); // } // }); // // // Train // Component trainLoadingIndicator = new LoadingIndicatorPanel("trainInformation"); // Component trainInformationPanel = new TrainInformationPanel("trainInformation", new TrainMessageAsyncModel()); // loadingComponents.put(trainInformationPanel, trainLoadingIndicator); // add(trainLoadingIndicator); // // // Twitter // Component twitterLoadingIndicator = new LoadingIndicatorPanel("twitterInformation"); // Component twitterInformationPanel = new TwitterInformationPanel("twitterInformation", new TwitterMessageAsyncModel()); // loadingComponents.put(twitterInformationPanel, twitterLoadingIndicator); // add(twitterLoadingIndicator); // // // Dilbert // Component dilbertLoadingIndicator = new LoadingIndicatorPanel("dilbertInformation"); // Component dilbertInformationPanel = new DilbertInformationPanel("dilbertInformation", new DilbertAsyncModel()); // loadingComponents.put(dilbertInformationPanel, dilbertLoadingIndicator); // add(dilbertLoadingIndicator); // // } // // @Override // protected void onConfigure() { // super.onConfigure(); // // // Das Laden in den einzelnen Komponenten anstoßen // for (Component asyncLoadingComponent : loadingComponents.keySet()) { // asyncLoadingComponent.getDefaultModel().getObject(); // } // // } // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/core/snow/LetItSnowComponentInstantiationListener.java // public class LetItSnowComponentInstantiationListener implements IComponentInstantiationListener { // // @Override // public void onInstantiation(Component component) { // if (component instanceof WebPage) { // component.add(new LetItSnowBehavior()); // } // } // // }
import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import com.senacor.wicket.async.christmas.app.lazyloading.LazyLoadingPage; import com.senacor.wicket.async.christmas.app.websocket.WebsocketPage; import com.senacor.wicket.async.christmas.core.snow.LetItSnowComponentInstantiationListener;
package com.senacor.wicket.async.christmas.app; public class ChristmasApplication extends WebApplication { @Override public Class<? extends WebPage> getHomePage() { return HomePage.class; } @Override public void init() { super.init(); mountPage("lazyloading", LazyLoadingPage.class); mountPage("websockets", WebsocketPage.class); getComponentInstantiationListeners().add(new SpringComponentInjector(this));
// Path: src/main/java/com/senacor/wicket/async/christmas/app/lazyloading/LazyLoadingPage.java // public class LazyLoadingPage extends WebPage { // // public LazyLoadingPage() { // // add(new PageRequestCounter("counter")); // // Panel trainInformationLazyLoadPanel = new AjaxLazyLoadPanel("trainInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TrainInformationPanel trainInformationPanel = new TrainInformationPanel(markupId, new TrainMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); // } // }; // return trainInformationPanel; // } // // }; // add(trainInformationLazyLoadPanel); // // Panel twitterInformationLazyLoadPanel = new AjaxLazyLoadPanel("twitterInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // TwitterInformationPanel twitterInformationPanel = new TwitterInformationPanel(markupId, new TwitterMessageBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15))); // } // }; // return twitterInformationPanel; // } // // }; // add(twitterInformationLazyLoadPanel); // // Panel dilbertInformationLazyLoadPanel = new AjaxLazyLoadPanel("dilbertInformationPanel") { // // @Override // public Component getLazyLoadComponent(String markupId) { // DilbertInformationPanel dilbertInformationPanel = new DilbertInformationPanel(markupId, new DilbertBlockingModel()) { // @Override // protected Component createTextComponent(String id, IModel<String> textModel) { // return super.createTextComponent(id, textModel).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(45))); // } // }; // return dilbertInformationPanel; // } // // }; // add(dilbertInformationLazyLoadPanel); // // } // } // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/WebsocketPage.java // public class WebsocketPage extends WebPage { // // private final ConcurrentHashMap<Component, Component> loadingComponents; // // public WebsocketPage() { // // loadingComponents = new ConcurrentHashMap<Component, Component>(); // // final PageRequestCounter pageRequestCounter = new PageRequestCounter("counter"); // add(pageRequestCounter); // // add(new UpdatingWebsocketBehavior(loadingComponents) { // @Override // protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { // super.onMessage(handler, message); // handler.add(pageRequestCounter); // } // }); // // // Train // Component trainLoadingIndicator = new LoadingIndicatorPanel("trainInformation"); // Component trainInformationPanel = new TrainInformationPanel("trainInformation", new TrainMessageAsyncModel()); // loadingComponents.put(trainInformationPanel, trainLoadingIndicator); // add(trainLoadingIndicator); // // // Twitter // Component twitterLoadingIndicator = new LoadingIndicatorPanel("twitterInformation"); // Component twitterInformationPanel = new TwitterInformationPanel("twitterInformation", new TwitterMessageAsyncModel()); // loadingComponents.put(twitterInformationPanel, twitterLoadingIndicator); // add(twitterLoadingIndicator); // // // Dilbert // Component dilbertLoadingIndicator = new LoadingIndicatorPanel("dilbertInformation"); // Component dilbertInformationPanel = new DilbertInformationPanel("dilbertInformation", new DilbertAsyncModel()); // loadingComponents.put(dilbertInformationPanel, dilbertLoadingIndicator); // add(dilbertLoadingIndicator); // // } // // @Override // protected void onConfigure() { // super.onConfigure(); // // // Das Laden in den einzelnen Komponenten anstoßen // for (Component asyncLoadingComponent : loadingComponents.keySet()) { // asyncLoadingComponent.getDefaultModel().getObject(); // } // // } // // } // // Path: src/main/java/com/senacor/wicket/async/christmas/core/snow/LetItSnowComponentInstantiationListener.java // public class LetItSnowComponentInstantiationListener implements IComponentInstantiationListener { // // @Override // public void onInstantiation(Component component) { // if (component instanceof WebPage) { // component.add(new LetItSnowBehavior()); // } // } // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/ChristmasApplication.java import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import com.senacor.wicket.async.christmas.app.lazyloading.LazyLoadingPage; import com.senacor.wicket.async.christmas.app.websocket.WebsocketPage; import com.senacor.wicket.async.christmas.core.snow.LetItSnowComponentInstantiationListener; package com.senacor.wicket.async.christmas.app; public class ChristmasApplication extends WebApplication { @Override public Class<? extends WebPage> getHomePage() { return HomePage.class; } @Override public void init() { super.init(); mountPage("lazyloading", LazyLoadingPage.class); mountPage("websockets", WebsocketPage.class); getComponentInstantiationListeners().add(new SpringComponentInjector(this));
getComponentInstantiationListeners().add(new LetItSnowComponentInstantiationListener());
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/badheart/ChangeVisiblityIfLoadedBehavior.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import org.apache.wicket.Component; import org.apache.wicket.ajax.AbstractAjaxTimerBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.util.time.Duration; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
package com.senacor.wicket.async.christmas.app.badheart; /** * Blendet den LoadingIndicator aus und das InformationPanel ein, sobald das * Laden abgeschlosssen ist. * * @author Olaf Siefart, Senacor Technologies AG */ public class ChangeVisiblityIfLoadedBehavior extends AbstractAjaxTimerBehavior { private final Component initial; private final Component replacement;
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/badheart/ChangeVisiblityIfLoadedBehavior.java import org.apache.wicket.Component; import org.apache.wicket.ajax.AbstractAjaxTimerBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.util.time.Duration; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; package com.senacor.wicket.async.christmas.app.badheart; /** * Blendet den LoadingIndicator aus und das InformationPanel ein, sobald das * Laden abgeschlosssen ist. * * @author Olaf Siefart, Senacor Technologies AG */ public class ChangeVisiblityIfLoadedBehavior extends AbstractAjaxTimerBehavior { private final Component initial; private final Component replacement;
private final IAsyncModel<?> model;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/websocket/UpdatingWebsocketBehavior.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java // public static final String REFRESH_MESSAGE = "refresh"; // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java // public static final String UPDATE_MESSAGE = "update"; // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import static com.senacor.wicket.async.christmas.app.websocket.SendRefreshMessageRunnable.REFRESH_MESSAGE; import static com.senacor.wicket.async.christmas.app.websocket.SendUpdateMessageRunnable.UPDATE_MESSAGE; import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import org.apache.wicket.ajax.WebSocketRequestHandler; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.protocol.ws.api.WebSocketBehavior; import org.apache.wicket.protocol.ws.api.message.ClosedMessage; import org.apache.wicket.protocol.ws.api.message.ConnectedMessage; import org.apache.wicket.protocol.ws.api.message.TextMessage; import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
package com.senacor.wicket.async.christmas.app.websocket; /** * * @author Olaf Siefart, Senacor Technologies AG */ public class UpdatingWebsocketBehavior extends WebSocketBehavior { private static final Logger LOG = LoggerFactory.getLogger(UpdatingWebsocketBehavior.class); // Variablen für den update-Mechanismus private final ConcurrentHashMap<Component, Component> asyncLoadingComponents; private final ConcurrentHashMap<Component, Component> updatableComponents; // Variablen für den refresh-Mechanismus private final List<Component> refreshableComponents; private final AtomicBoolean finishThread; public UpdatingWebsocketBehavior(ConcurrentHashMap<Component, Component> loadingComponents) { // Variablen für den update-Mechanismus this.asyncLoadingComponents = loadingComponents; updatableComponents = new ConcurrentHashMap<Component, Component>(); // Variablen für den refresh-Mechanismus refreshableComponents = new CopyOnWriteArrayList<Component>(); finishThread = new AtomicBoolean(false); } @Override protected void onConnect(ConnectedMessage message) { super.onConnect(message); // Das Laden in den einzelnen Komponenten anstoßen ThreadContext threadContext = ThreadContext.get(false); // Start the update thread Thread updateThread = new Thread(new SendUpdateMessageRunnable(threadContext, asyncLoadingComponents, updatableComponents, message.getPageId(), message.getSessionId())); updateThread.start(); // Start the refresh thread Thread refreshThread = new Thread(new SendRefreshMessageRunnable(threadContext, refreshableComponents, finishThread, message.getPageId(), message.getSessionId())); refreshThread.start(); } @Override protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { super.onMessage(handler, message);
// Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java // public static final String REFRESH_MESSAGE = "refresh"; // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java // public static final String UPDATE_MESSAGE = "update"; // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/UpdatingWebsocketBehavior.java import static com.senacor.wicket.async.christmas.app.websocket.SendRefreshMessageRunnable.REFRESH_MESSAGE; import static com.senacor.wicket.async.christmas.app.websocket.SendUpdateMessageRunnable.UPDATE_MESSAGE; import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import org.apache.wicket.ajax.WebSocketRequestHandler; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.protocol.ws.api.WebSocketBehavior; import org.apache.wicket.protocol.ws.api.message.ClosedMessage; import org.apache.wicket.protocol.ws.api.message.ConnectedMessage; import org.apache.wicket.protocol.ws.api.message.TextMessage; import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; package com.senacor.wicket.async.christmas.app.websocket; /** * * @author Olaf Siefart, Senacor Technologies AG */ public class UpdatingWebsocketBehavior extends WebSocketBehavior { private static final Logger LOG = LoggerFactory.getLogger(UpdatingWebsocketBehavior.class); // Variablen für den update-Mechanismus private final ConcurrentHashMap<Component, Component> asyncLoadingComponents; private final ConcurrentHashMap<Component, Component> updatableComponents; // Variablen für den refresh-Mechanismus private final List<Component> refreshableComponents; private final AtomicBoolean finishThread; public UpdatingWebsocketBehavior(ConcurrentHashMap<Component, Component> loadingComponents) { // Variablen für den update-Mechanismus this.asyncLoadingComponents = loadingComponents; updatableComponents = new ConcurrentHashMap<Component, Component>(); // Variablen für den refresh-Mechanismus refreshableComponents = new CopyOnWriteArrayList<Component>(); finishThread = new AtomicBoolean(false); } @Override protected void onConnect(ConnectedMessage message) { super.onConnect(message); // Das Laden in den einzelnen Komponenten anstoßen ThreadContext threadContext = ThreadContext.get(false); // Start the update thread Thread updateThread = new Thread(new SendUpdateMessageRunnable(threadContext, asyncLoadingComponents, updatableComponents, message.getPageId(), message.getSessionId())); updateThread.start(); // Start the refresh thread Thread refreshThread = new Thread(new SendRefreshMessageRunnable(threadContext, refreshableComponents, finishThread, message.getPageId(), message.getSessionId())); refreshThread.start(); } @Override protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { super.onMessage(handler, message);
if (UPDATE_MESSAGE.equals(message.getText())) {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/websocket/UpdatingWebsocketBehavior.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java // public static final String REFRESH_MESSAGE = "refresh"; // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java // public static final String UPDATE_MESSAGE = "update"; // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import static com.senacor.wicket.async.christmas.app.websocket.SendRefreshMessageRunnable.REFRESH_MESSAGE; import static com.senacor.wicket.async.christmas.app.websocket.SendUpdateMessageRunnable.UPDATE_MESSAGE; import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import org.apache.wicket.ajax.WebSocketRequestHandler; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.protocol.ws.api.WebSocketBehavior; import org.apache.wicket.protocol.ws.api.message.ClosedMessage; import org.apache.wicket.protocol.ws.api.message.ConnectedMessage; import org.apache.wicket.protocol.ws.api.message.TextMessage; import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
package com.senacor.wicket.async.christmas.app.websocket; /** * * @author Olaf Siefart, Senacor Technologies AG */ public class UpdatingWebsocketBehavior extends WebSocketBehavior { private static final Logger LOG = LoggerFactory.getLogger(UpdatingWebsocketBehavior.class); // Variablen für den update-Mechanismus private final ConcurrentHashMap<Component, Component> asyncLoadingComponents; private final ConcurrentHashMap<Component, Component> updatableComponents; // Variablen für den refresh-Mechanismus private final List<Component> refreshableComponents; private final AtomicBoolean finishThread; public UpdatingWebsocketBehavior(ConcurrentHashMap<Component, Component> loadingComponents) { // Variablen für den update-Mechanismus this.asyncLoadingComponents = loadingComponents; updatableComponents = new ConcurrentHashMap<Component, Component>(); // Variablen für den refresh-Mechanismus refreshableComponents = new CopyOnWriteArrayList<Component>(); finishThread = new AtomicBoolean(false); } @Override protected void onConnect(ConnectedMessage message) { super.onConnect(message); // Das Laden in den einzelnen Komponenten anstoßen ThreadContext threadContext = ThreadContext.get(false); // Start the update thread Thread updateThread = new Thread(new SendUpdateMessageRunnable(threadContext, asyncLoadingComponents, updatableComponents, message.getPageId(), message.getSessionId())); updateThread.start(); // Start the refresh thread Thread refreshThread = new Thread(new SendRefreshMessageRunnable(threadContext, refreshableComponents, finishThread, message.getPageId(), message.getSessionId())); refreshThread.start(); } @Override protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { super.onMessage(handler, message); if (UPDATE_MESSAGE.equals(message.getText())) { LOG.info("websocket message: " + message.getText()); update(handler);
// Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java // public static final String REFRESH_MESSAGE = "refresh"; // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java // public static final String UPDATE_MESSAGE = "update"; // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/UpdatingWebsocketBehavior.java import static com.senacor.wicket.async.christmas.app.websocket.SendRefreshMessageRunnable.REFRESH_MESSAGE; import static com.senacor.wicket.async.christmas.app.websocket.SendUpdateMessageRunnable.UPDATE_MESSAGE; import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import org.apache.wicket.ajax.WebSocketRequestHandler; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.protocol.ws.api.WebSocketBehavior; import org.apache.wicket.protocol.ws.api.message.ClosedMessage; import org.apache.wicket.protocol.ws.api.message.ConnectedMessage; import org.apache.wicket.protocol.ws.api.message.TextMessage; import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; package com.senacor.wicket.async.christmas.app.websocket; /** * * @author Olaf Siefart, Senacor Technologies AG */ public class UpdatingWebsocketBehavior extends WebSocketBehavior { private static final Logger LOG = LoggerFactory.getLogger(UpdatingWebsocketBehavior.class); // Variablen für den update-Mechanismus private final ConcurrentHashMap<Component, Component> asyncLoadingComponents; private final ConcurrentHashMap<Component, Component> updatableComponents; // Variablen für den refresh-Mechanismus private final List<Component> refreshableComponents; private final AtomicBoolean finishThread; public UpdatingWebsocketBehavior(ConcurrentHashMap<Component, Component> loadingComponents) { // Variablen für den update-Mechanismus this.asyncLoadingComponents = loadingComponents; updatableComponents = new ConcurrentHashMap<Component, Component>(); // Variablen für den refresh-Mechanismus refreshableComponents = new CopyOnWriteArrayList<Component>(); finishThread = new AtomicBoolean(false); } @Override protected void onConnect(ConnectedMessage message) { super.onConnect(message); // Das Laden in den einzelnen Komponenten anstoßen ThreadContext threadContext = ThreadContext.get(false); // Start the update thread Thread updateThread = new Thread(new SendUpdateMessageRunnable(threadContext, asyncLoadingComponents, updatableComponents, message.getPageId(), message.getSessionId())); updateThread.start(); // Start the refresh thread Thread refreshThread = new Thread(new SendRefreshMessageRunnable(threadContext, refreshableComponents, finishThread, message.getPageId(), message.getSessionId())); refreshThread.start(); } @Override protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { super.onMessage(handler, message); if (UPDATE_MESSAGE.equals(message.getText())) { LOG.info("websocket message: " + message.getText()); update(handler);
} else if (REFRESH_MESSAGE.equals(message.getText())) {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/app/websocket/UpdatingWebsocketBehavior.java
// Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java // public static final String REFRESH_MESSAGE = "refresh"; // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java // public static final String UPDATE_MESSAGE = "update"; // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // }
import static com.senacor.wicket.async.christmas.app.websocket.SendRefreshMessageRunnable.REFRESH_MESSAGE; import static com.senacor.wicket.async.christmas.app.websocket.SendUpdateMessageRunnable.UPDATE_MESSAGE; import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import org.apache.wicket.ajax.WebSocketRequestHandler; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.protocol.ws.api.WebSocketBehavior; import org.apache.wicket.protocol.ws.api.message.ClosedMessage; import org.apache.wicket.protocol.ws.api.message.ConnectedMessage; import org.apache.wicket.protocol.ws.api.message.TextMessage; import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel;
message.getSessionId())); updateThread.start(); // Start the refresh thread Thread refreshThread = new Thread(new SendRefreshMessageRunnable(threadContext, refreshableComponents, finishThread, message.getPageId(), message.getSessionId())); refreshThread.start(); } @Override protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { super.onMessage(handler, message); if (UPDATE_MESSAGE.equals(message.getText())) { LOG.info("websocket message: " + message.getText()); update(handler); } else if (REFRESH_MESSAGE.equals(message.getText())) { LOG.info("websocket message: " + message.getText()); refresh(handler); } else { LOG.error("Unknown websocket message: " + message.getText()); } } private void refresh(WebSocketRequestHandler handler) { for (Component component : refreshableComponents) { // Notwendig wegen vermutlichem Bug im wicket websocket framework RequestCycle.get().getUrlRenderer().setBaseUrl(Url.parse("websockets"));
// Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendRefreshMessageRunnable.java // public static final String REFRESH_MESSAGE = "refresh"; // // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/SendUpdateMessageRunnable.java // public static final String UPDATE_MESSAGE = "update"; // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/IAsyncModel.java // public interface IAsyncModel<T> extends IModel<T> { // // Boolean isLoading(); // // void startLoading(); // // Boolean hasNext(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/app/websocket/UpdatingWebsocketBehavior.java import static com.senacor.wicket.async.christmas.app.websocket.SendRefreshMessageRunnable.REFRESH_MESSAGE; import static com.senacor.wicket.async.christmas.app.websocket.SendUpdateMessageRunnable.UPDATE_MESSAGE; import static org.apache.commons.lang.BooleanUtils.isTrue; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.wicket.Component; import org.apache.wicket.ThreadContext; import org.apache.wicket.ajax.WebSocketRequestHandler; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.protocol.ws.api.WebSocketBehavior; import org.apache.wicket.protocol.ws.api.message.ClosedMessage; import org.apache.wicket.protocol.ws.api.message.ConnectedMessage; import org.apache.wicket.protocol.ws.api.message.TextMessage; import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.senacor.wicket.async.christmas.widgets.api.model.IAsyncModel; message.getSessionId())); updateThread.start(); // Start the refresh thread Thread refreshThread = new Thread(new SendRefreshMessageRunnable(threadContext, refreshableComponents, finishThread, message.getPageId(), message.getSessionId())); refreshThread.start(); } @Override protected void onMessage(WebSocketRequestHandler handler, TextMessage message) { super.onMessage(handler, message); if (UPDATE_MESSAGE.equals(message.getText())) { LOG.info("websocket message: " + message.getText()); update(handler); } else if (REFRESH_MESSAGE.equals(message.getText())) { LOG.info("websocket message: " + message.getText()); refresh(handler); } else { LOG.error("Unknown websocket message: " + message.getText()); } } private void refresh(WebSocketRequestHandler handler) { for (Component component : refreshableComponents) { // Notwendig wegen vermutlichem Bug im wicket websocket framework RequestCycle.get().getUrlRenderer().setBaseUrl(Url.parse("websockets"));
IAsyncModel<?> model = (IAsyncModel<?>) component.getDefaultModel();
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/source/FileStringSource.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/IStringSource.java // public interface IStringSource { // String getCitiesAndStations(); // // String getTrains(DateTime date); // }
import java.io.StringWriter; import org.apache.commons.io.IOUtils; import org.joda.time.DateTime; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; import com.senacor.wicket.async.christmas.core.runtime.delay.Delay; import com.senacor.wicket.async.christmas.core.runtime.profile.Dev; import com.senacor.wicket.async.christmas.widgets.train.message.IStringSource;
package com.senacor.wicket.async.christmas.widgets.train.message.source; /** * @author Jochen Mader */ @Repository @Scope("prototype") @Dev
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/IStringSource.java // public interface IStringSource { // String getCitiesAndStations(); // // String getTrains(DateTime date); // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/train/message/source/FileStringSource.java import java.io.StringWriter; import org.apache.commons.io.IOUtils; import org.joda.time.DateTime; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; import com.senacor.wicket.async.christmas.core.runtime.delay.Delay; import com.senacor.wicket.async.christmas.core.runtime.profile.Dev; import com.senacor.wicket.async.christmas.widgets.train.message.IStringSource; package com.senacor.wicket.async.christmas.widgets.train.message.source; /** * @author Jochen Mader */ @Repository @Scope("prototype") @Dev
public class FileStringSource implements IStringSource {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageLoader.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // }
import java.net.URL; import java.util.List; import java.util.concurrent.Future; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.profile.Prod; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.io.SyndFeedInput; import com.sun.syndication.io.XmlReader;
package com.senacor.wicket.async.christmas.widgets.dilbert.message; /** * @author Jochen Mader */ @Service("dilbertMessageLoader") @Prod
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageLoader.java // public interface IMessageLoader<T> { // // @Async // Future<List<T>> load(); // // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageLoader.java import java.net.URL; import java.util.List; import java.util.concurrent.Future; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import com.senacor.wicket.async.christmas.core.runtime.profile.Prod; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageLoader; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.io.SyndFeedInput; import com.sun.syndication.io.XmlReader; package com.senacor.wicket.async.christmas.widgets.dilbert.message; /** * @author Jochen Mader */ @Service("dilbertMessageLoader") @Prod
public class DilbertMessageLoader implements IMessageLoader<SyndFeed> {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed;
package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertBlockingModel extends AbstractBlockingModel<SyndFeed> { @Autowired
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertBlockingModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed; package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertBlockingModel extends AbstractBlockingModel<SyndFeed> { @Autowired
private transient DilbertMessageSource messageSource;
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // }
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed;
package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertBlockingModel extends AbstractBlockingModel<SyndFeed> { @Autowired private transient DilbertMessageSource messageSource; @Override
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java // public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { // // @Override // public T getObject() { // return getMessageSource().getMessageSync(); // } // // @Override // public Boolean isLoading() { // return getMessageSource().isLoading(); // } // // @Override // public void startLoading() { // getMessageSource().loadNext(); // } // // @Override // public Boolean hasNext() { // return getMessageSource().hasNext(); // } // // protected abstract IMessageSource<T> getMessageSource(); // } // // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/message/DilbertMessageSource.java // @Service // @Scope(value = "prototype") // public class DilbertMessageSource extends MessageSource<SyndFeed> { // // @Autowired // @Qualifier("dilbertMessageLoader") // private IMessageLoader<SyndFeed> messageLoader; // // @Override // public IMessageLoader<SyndFeed> getMessageLoader() { // return messageLoader; // } // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/dilbert/DilbertBlockingModel.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; import com.senacor.wicket.async.christmas.widgets.api.model.AbstractBlockingModel; import com.senacor.wicket.async.christmas.widgets.dilbert.message.DilbertMessageSource; import com.sun.syndication.feed.synd.SyndFeed; package com.senacor.wicket.async.christmas.widgets.dilbert; @Configurable public class DilbertBlockingModel extends AbstractBlockingModel<SyndFeed> { @Autowired private transient DilbertMessageSource messageSource; @Override
public IMessageSource<SyndFeed> getMessageSource() {
osiefart/wicket-christmas
src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // }
import org.apache.wicket.model.AbstractReadOnlyModel; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource;
package com.senacor.wicket.async.christmas.widgets.api.model; /** * Model that blocks the Thread and waits for the Result of the loading call. * * @author Olaf Siefart, Senacor Technologies AG */ public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { @Override public T getObject() { return getMessageSource().getMessageSync(); } @Override public Boolean isLoading() { return getMessageSource().isLoading(); } @Override public void startLoading() { getMessageSource().loadNext(); } @Override public Boolean hasNext() { return getMessageSource().hasNext(); }
// Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/message/IMessageSource.java // public interface IMessageSource<T> { // // T getMessage(); // // T getMessageSync(); // // Boolean isLoading(); // // Boolean hasNext(); // // void loadNext(); // } // Path: src/main/java/com/senacor/wicket/async/christmas/widgets/api/model/AbstractBlockingModel.java import org.apache.wicket.model.AbstractReadOnlyModel; import com.senacor.wicket.async.christmas.widgets.api.message.IMessageSource; package com.senacor.wicket.async.christmas.widgets.api.model; /** * Model that blocks the Thread and waits for the Result of the loading call. * * @author Olaf Siefart, Senacor Technologies AG */ public abstract class AbstractBlockingModel<T> extends AbstractReadOnlyModel<T> implements IAsyncModel<T> { @Override public T getObject() { return getMessageSource().getMessageSync(); } @Override public Boolean isLoading() { return getMessageSource().isLoading(); } @Override public void startLoading() { getMessageSource().loadNext(); } @Override public Boolean hasNext() { return getMessageSource().hasNext(); }
protected abstract IMessageSource<T> getMessageSource();
Darkhogg/LWJTorrent
src/es/darkhogg/torrent/tracker/PeerInfo.java
// Path: src/es/darkhogg/torrent/data/PeerId.java // public final class PeerId { // // /** // * LATIN-1 charset // */ // private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); // // /** // * Peer ID as an array of bytes // */ // private final byte[] bytes; // // /** // * Peer ID as a String // */ // private final String string; // // /** // * Cached hash-code // */ // private final int hash; // // /** // * Cached URL-encoded string // */ // private final String urlEncodedString; // // /** // * Constructs a peer ID using an array of bytes // * // * @param bytes Peer ID // * @throws NullPointerException if <tt>bytes</tt> is <tt>null</tt> // * @throws IllegalArgumentException if <tt>bytes</tt> has a different length than 20 // */ // public PeerId (byte[] bytes) { // if (bytes == null) { // throw new NullPointerException(); // } // // if (bytes.length != 20) { // throw new IllegalArgumentException(); // } // // this.bytes = Arrays.copyOf(bytes, bytes.length); // this.string = new String(bytes, ISO_8859_1); // this.hash = Arrays.hashCode(bytes); // // // URL Encoded String // try { // urlEncodedString = URLEncoder.encode(string, "ISO-8859-1"); // } catch (UnsupportedEncodingException e) { // // Should not happen, as LATIN-1 is always supported... // throw new AssertionError(); // } // } // // /** // * Constructs a peer ID using a string. // * // * @param string Peer ID // * @throws NullPointerException if <tt>string</tt> is <tt>null</tt> // * @throws IllegalArgumentException if <tt>string</tt> has a different length than 20 // */ // public PeerId (String string) { // if (string == null) { // throw new NullPointerException(); // } // // if (string.length() != 20) { // throw new IllegalArgumentException(); // } // // this.bytes = string.getBytes(ISO_8859_1); // this.string = string; // this.hash = Arrays.hashCode(bytes); // // // URL Encoded String // try { // urlEncodedString = URLEncoder.encode(string, "ISO-8859-1"); // } catch (UnsupportedEncodingException e) { // // Should not happen, as LATIN-1 is always supported... // throw new AssertionError(); // } // } // // /** // * Returns this peer ID as an array of bytes. // * // * @return A 20-bytes array // */ // public byte[] getBytes () { // return Arrays.copyOf(bytes, bytes.length); // } // // /** // * Compares this peer ID to another one for equality. // * <p> // * A <tt>PeerID</tt> is equal only to another <tt>PeerID</tt> object that represents the same peer ID as this // * object. // */ // @Override // public boolean equals (Object obj) { // if (!(obj instanceof PeerId)) { // return false; // } // // PeerId p = (PeerId) obj; // return Arrays.equals(p.bytes, bytes); // } // // @Override // public int hashCode () { // return hash; // } // // /** // * Returns the peer ID as a string object // */ // @Override // public String toString () { // return string; // } // // /** // * Returns the same string as {@link #toString}, but URL-encoded. // * // * @return This peer ID as an URL-encoded string // */ // public String toUrlEncodedString () { // return urlEncodedString; // } // }
import java.net.InetSocketAddress; import es.darkhogg.torrent.data.PeerId;
package es.darkhogg.torrent.tracker; /** * Stores information about a peer, such as its peer ID and its IP/port. * * @author Daniel Escoz * @version 1.0 */ public class PeerInfo { /** * Address and port of the peer */ private final InetSocketAddress address; /** * Peer ID */
// Path: src/es/darkhogg/torrent/data/PeerId.java // public final class PeerId { // // /** // * LATIN-1 charset // */ // private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); // // /** // * Peer ID as an array of bytes // */ // private final byte[] bytes; // // /** // * Peer ID as a String // */ // private final String string; // // /** // * Cached hash-code // */ // private final int hash; // // /** // * Cached URL-encoded string // */ // private final String urlEncodedString; // // /** // * Constructs a peer ID using an array of bytes // * // * @param bytes Peer ID // * @throws NullPointerException if <tt>bytes</tt> is <tt>null</tt> // * @throws IllegalArgumentException if <tt>bytes</tt> has a different length than 20 // */ // public PeerId (byte[] bytes) { // if (bytes == null) { // throw new NullPointerException(); // } // // if (bytes.length != 20) { // throw new IllegalArgumentException(); // } // // this.bytes = Arrays.copyOf(bytes, bytes.length); // this.string = new String(bytes, ISO_8859_1); // this.hash = Arrays.hashCode(bytes); // // // URL Encoded String // try { // urlEncodedString = URLEncoder.encode(string, "ISO-8859-1"); // } catch (UnsupportedEncodingException e) { // // Should not happen, as LATIN-1 is always supported... // throw new AssertionError(); // } // } // // /** // * Constructs a peer ID using a string. // * // * @param string Peer ID // * @throws NullPointerException if <tt>string</tt> is <tt>null</tt> // * @throws IllegalArgumentException if <tt>string</tt> has a different length than 20 // */ // public PeerId (String string) { // if (string == null) { // throw new NullPointerException(); // } // // if (string.length() != 20) { // throw new IllegalArgumentException(); // } // // this.bytes = string.getBytes(ISO_8859_1); // this.string = string; // this.hash = Arrays.hashCode(bytes); // // // URL Encoded String // try { // urlEncodedString = URLEncoder.encode(string, "ISO-8859-1"); // } catch (UnsupportedEncodingException e) { // // Should not happen, as LATIN-1 is always supported... // throw new AssertionError(); // } // } // // /** // * Returns this peer ID as an array of bytes. // * // * @return A 20-bytes array // */ // public byte[] getBytes () { // return Arrays.copyOf(bytes, bytes.length); // } // // /** // * Compares this peer ID to another one for equality. // * <p> // * A <tt>PeerID</tt> is equal only to another <tt>PeerID</tt> object that represents the same peer ID as this // * object. // */ // @Override // public boolean equals (Object obj) { // if (!(obj instanceof PeerId)) { // return false; // } // // PeerId p = (PeerId) obj; // return Arrays.equals(p.bytes, bytes); // } // // @Override // public int hashCode () { // return hash; // } // // /** // * Returns the peer ID as a string object // */ // @Override // public String toString () { // return string; // } // // /** // * Returns the same string as {@link #toString}, but URL-encoded. // * // * @return This peer ID as an URL-encoded string // */ // public String toUrlEncodedString () { // return urlEncodedString; // } // } // Path: src/es/darkhogg/torrent/tracker/PeerInfo.java import java.net.InetSocketAddress; import es.darkhogg.torrent.data.PeerId; package es.darkhogg.torrent.tracker; /** * Stores information about a peer, such as its peer ID and its IP/port. * * @author Daniel Escoz * @version 1.0 */ public class PeerInfo { /** * Address and port of the peer */ private final InetSocketAddress address; /** * Peer ID */
private final PeerId peerId;
Darkhogg/LWJTorrent
src/es/darkhogg/torrent/data/Sha1Hash.java
// Path: src/es/darkhogg/torrent/bencode/BencodeOutputStream.java // public final class BencodeOutputStream implements Closeable, Flushable { // // /** The actual stream used to write bencode values */ // private final PrintStream stream; // // /** // * Constructs a BencodeOutputStream that writes bencoded values to the given OutputStream // * // * @param out Stream to wrap in this object // */ // public BencodeOutputStream (final OutputStream out) { // try { // stream = new PrintStream(out, false, Bencode.UTF8.name()); // // } catch (UnsupportedEncodingException exc) { // // If this ever happens, something seriously wrong is going on with the JVM. // // Notice that the charset name is obtained from an actual charset which, obviously, is supported. // throw new AssertionError(exc); // } // } // // /** // * Constructs a BencodeInputStream that writes bencoded values to the specified file // * // * @param file The file to open // * @throws FileNotFoundException if the file doesn't exist // */ // public BencodeOutputStream (final File file) throws FileNotFoundException { // this(new FileOutputStream(file)); // } // // /** // * Writes a bencoded value into the wrapped stream // * // * @param value The value to write // * @throws IOException If some I/O error occurs // */ // public void writeValue (final Value<?> value) throws IOException { // if (value instanceof StringValue) { // final StringValue sv = (StringValue) value; // stream.print(sv.getValueLength()); // stream.print(':'); // stream.write(sv.getValue()); // // } else if (value instanceof IntegerValue) { // final IntegerValue iv = (IntegerValue) value; // stream.print('i'); // stream.print(iv.getValue()); // stream.print('e'); // // } else if (value instanceof ListValue) { // final ListValue lv = (ListValue) value; // stream.print('l'); // for (final Value<?> val : lv.getValue()) { // writeValue(val); // } // stream.print('e'); // // } else if (value instanceof DictionaryValue) { // final DictionaryValue dv = (DictionaryValue) value; // stream.print('d'); // for (final Map.Entry<String,Value<?>> me : dv.getValue().entrySet()) { // writeValue(new StringValue(me.getKey())); // writeValue(me.getValue()); // } // stream.print('e'); // // } else { // throw new IllegalArgumentException("Invalid value type"); // } // } // // @Override // public void close () { // stream.close(); // } // // @Override // public void flush () { // stream.flush(); // } // } // // Path: src/es/darkhogg/torrent/bencode/Value.java // public abstract class Value<T> { // // /** // * Creates this object with the given initial value // * // * @param value Initial value // */ // /* package-private */Value (final T value) { // setValue(value); // } // // /** // * Gets the current value for this object // * // * @return This object value // */ // public abstract T getValue (); // // /** // * Sets a new value for this object // * // * @param value New value // */ // public abstract void setValue (T value); // // /** // * Returns the length, in bytes, this value will take up when encoded using UTF-8 as the encoding character set. // * <p> // * If the size cannot be determined accurately, an upper bound must be returned. // * // * @return The length of the encoded byte stream for this value // */ // public abstract long getEncodedLength (); // // }
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import es.darkhogg.torrent.bencode.BencodeOutputStream; import es.darkhogg.torrent.bencode.Value;
} /** * Returns a 40-character uppercase <tt>String</tt> representing the hexadecimal value of the hash represented by * this object. */ @Override public String toString () { return string; } /** * Returns the binary representation of this hash as an URL-encoded string * * @return An URL-encoded string representing this hash */ public String toUrlEncodedString () { return urlEncodedString; } /** * Returns a <tt>Sha1Hash</tt> object representing the SHA-1 hash of the given bencode <tt>Value</tt>. The passed * value is re-encoded, but only at most 64 bytes are buffered at any given time to compute the SHA-1 hash. * <p> * If the encoding fails for some reason or the SHA-1 algorithm is not available in this JVM, this method returns * <tt>null</tt>. * * @param value The value to hash * @return The hash of the <tt>value</tt> argument, or <tt>null</tt> if it cannot be calculated for some reason. */
// Path: src/es/darkhogg/torrent/bencode/BencodeOutputStream.java // public final class BencodeOutputStream implements Closeable, Flushable { // // /** The actual stream used to write bencode values */ // private final PrintStream stream; // // /** // * Constructs a BencodeOutputStream that writes bencoded values to the given OutputStream // * // * @param out Stream to wrap in this object // */ // public BencodeOutputStream (final OutputStream out) { // try { // stream = new PrintStream(out, false, Bencode.UTF8.name()); // // } catch (UnsupportedEncodingException exc) { // // If this ever happens, something seriously wrong is going on with the JVM. // // Notice that the charset name is obtained from an actual charset which, obviously, is supported. // throw new AssertionError(exc); // } // } // // /** // * Constructs a BencodeInputStream that writes bencoded values to the specified file // * // * @param file The file to open // * @throws FileNotFoundException if the file doesn't exist // */ // public BencodeOutputStream (final File file) throws FileNotFoundException { // this(new FileOutputStream(file)); // } // // /** // * Writes a bencoded value into the wrapped stream // * // * @param value The value to write // * @throws IOException If some I/O error occurs // */ // public void writeValue (final Value<?> value) throws IOException { // if (value instanceof StringValue) { // final StringValue sv = (StringValue) value; // stream.print(sv.getValueLength()); // stream.print(':'); // stream.write(sv.getValue()); // // } else if (value instanceof IntegerValue) { // final IntegerValue iv = (IntegerValue) value; // stream.print('i'); // stream.print(iv.getValue()); // stream.print('e'); // // } else if (value instanceof ListValue) { // final ListValue lv = (ListValue) value; // stream.print('l'); // for (final Value<?> val : lv.getValue()) { // writeValue(val); // } // stream.print('e'); // // } else if (value instanceof DictionaryValue) { // final DictionaryValue dv = (DictionaryValue) value; // stream.print('d'); // for (final Map.Entry<String,Value<?>> me : dv.getValue().entrySet()) { // writeValue(new StringValue(me.getKey())); // writeValue(me.getValue()); // } // stream.print('e'); // // } else { // throw new IllegalArgumentException("Invalid value type"); // } // } // // @Override // public void close () { // stream.close(); // } // // @Override // public void flush () { // stream.flush(); // } // } // // Path: src/es/darkhogg/torrent/bencode/Value.java // public abstract class Value<T> { // // /** // * Creates this object with the given initial value // * // * @param value Initial value // */ // /* package-private */Value (final T value) { // setValue(value); // } // // /** // * Gets the current value for this object // * // * @return This object value // */ // public abstract T getValue (); // // /** // * Sets a new value for this object // * // * @param value New value // */ // public abstract void setValue (T value); // // /** // * Returns the length, in bytes, this value will take up when encoded using UTF-8 as the encoding character set. // * <p> // * If the size cannot be determined accurately, an upper bound must be returned. // * // * @return The length of the encoded byte stream for this value // */ // public abstract long getEncodedLength (); // // } // Path: src/es/darkhogg/torrent/data/Sha1Hash.java import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import es.darkhogg.torrent.bencode.BencodeOutputStream; import es.darkhogg.torrent.bencode.Value; } /** * Returns a 40-character uppercase <tt>String</tt> representing the hexadecimal value of the hash represented by * this object. */ @Override public String toString () { return string; } /** * Returns the binary representation of this hash as an URL-encoded string * * @return An URL-encoded string representing this hash */ public String toUrlEncodedString () { return urlEncodedString; } /** * Returns a <tt>Sha1Hash</tt> object representing the SHA-1 hash of the given bencode <tt>Value</tt>. The passed * value is re-encoded, but only at most 64 bytes are buffered at any given time to compute the SHA-1 hash. * <p> * If the encoding fails for some reason or the SHA-1 algorithm is not available in this JVM, this method returns * <tt>null</tt>. * * @param value The value to hash * @return The hash of the <tt>value</tt> argument, or <tt>null</tt> if it cannot be calculated for some reason. */
public static Sha1Hash forValue (Value<?> value) {
Darkhogg/LWJTorrent
src/es/darkhogg/torrent/data/Sha1Hash.java
// Path: src/es/darkhogg/torrent/bencode/BencodeOutputStream.java // public final class BencodeOutputStream implements Closeable, Flushable { // // /** The actual stream used to write bencode values */ // private final PrintStream stream; // // /** // * Constructs a BencodeOutputStream that writes bencoded values to the given OutputStream // * // * @param out Stream to wrap in this object // */ // public BencodeOutputStream (final OutputStream out) { // try { // stream = new PrintStream(out, false, Bencode.UTF8.name()); // // } catch (UnsupportedEncodingException exc) { // // If this ever happens, something seriously wrong is going on with the JVM. // // Notice that the charset name is obtained from an actual charset which, obviously, is supported. // throw new AssertionError(exc); // } // } // // /** // * Constructs a BencodeInputStream that writes bencoded values to the specified file // * // * @param file The file to open // * @throws FileNotFoundException if the file doesn't exist // */ // public BencodeOutputStream (final File file) throws FileNotFoundException { // this(new FileOutputStream(file)); // } // // /** // * Writes a bencoded value into the wrapped stream // * // * @param value The value to write // * @throws IOException If some I/O error occurs // */ // public void writeValue (final Value<?> value) throws IOException { // if (value instanceof StringValue) { // final StringValue sv = (StringValue) value; // stream.print(sv.getValueLength()); // stream.print(':'); // stream.write(sv.getValue()); // // } else if (value instanceof IntegerValue) { // final IntegerValue iv = (IntegerValue) value; // stream.print('i'); // stream.print(iv.getValue()); // stream.print('e'); // // } else if (value instanceof ListValue) { // final ListValue lv = (ListValue) value; // stream.print('l'); // for (final Value<?> val : lv.getValue()) { // writeValue(val); // } // stream.print('e'); // // } else if (value instanceof DictionaryValue) { // final DictionaryValue dv = (DictionaryValue) value; // stream.print('d'); // for (final Map.Entry<String,Value<?>> me : dv.getValue().entrySet()) { // writeValue(new StringValue(me.getKey())); // writeValue(me.getValue()); // } // stream.print('e'); // // } else { // throw new IllegalArgumentException("Invalid value type"); // } // } // // @Override // public void close () { // stream.close(); // } // // @Override // public void flush () { // stream.flush(); // } // } // // Path: src/es/darkhogg/torrent/bencode/Value.java // public abstract class Value<T> { // // /** // * Creates this object with the given initial value // * // * @param value Initial value // */ // /* package-private */Value (final T value) { // setValue(value); // } // // /** // * Gets the current value for this object // * // * @return This object value // */ // public abstract T getValue (); // // /** // * Sets a new value for this object // * // * @param value New value // */ // public abstract void setValue (T value); // // /** // * Returns the length, in bytes, this value will take up when encoded using UTF-8 as the encoding character set. // * <p> // * If the size cannot be determined accurately, an upper bound must be returned. // * // * @return The length of the encoded byte stream for this value // */ // public abstract long getEncodedLength (); // // }
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import es.darkhogg.torrent.bencode.BencodeOutputStream; import es.darkhogg.torrent.bencode.Value;
} /** * Returns the binary representation of this hash as an URL-encoded string * * @return An URL-encoded string representing this hash */ public String toUrlEncodedString () { return urlEncodedString; } /** * Returns a <tt>Sha1Hash</tt> object representing the SHA-1 hash of the given bencode <tt>Value</tt>. The passed * value is re-encoded, but only at most 64 bytes are buffered at any given time to compute the SHA-1 hash. * <p> * If the encoding fails for some reason or the SHA-1 algorithm is not available in this JVM, this method returns * <tt>null</tt>. * * @param value The value to hash * @return The hash of the <tt>value</tt> argument, or <tt>null</tt> if it cannot be calculated for some reason. */ public static Sha1Hash forValue (Value<?> value) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA1"); } catch (NoSuchAlgorithmException e) { // If the SHA1 algorithm doesn't exist, returns null return null; }
// Path: src/es/darkhogg/torrent/bencode/BencodeOutputStream.java // public final class BencodeOutputStream implements Closeable, Flushable { // // /** The actual stream used to write bencode values */ // private final PrintStream stream; // // /** // * Constructs a BencodeOutputStream that writes bencoded values to the given OutputStream // * // * @param out Stream to wrap in this object // */ // public BencodeOutputStream (final OutputStream out) { // try { // stream = new PrintStream(out, false, Bencode.UTF8.name()); // // } catch (UnsupportedEncodingException exc) { // // If this ever happens, something seriously wrong is going on with the JVM. // // Notice that the charset name is obtained from an actual charset which, obviously, is supported. // throw new AssertionError(exc); // } // } // // /** // * Constructs a BencodeInputStream that writes bencoded values to the specified file // * // * @param file The file to open // * @throws FileNotFoundException if the file doesn't exist // */ // public BencodeOutputStream (final File file) throws FileNotFoundException { // this(new FileOutputStream(file)); // } // // /** // * Writes a bencoded value into the wrapped stream // * // * @param value The value to write // * @throws IOException If some I/O error occurs // */ // public void writeValue (final Value<?> value) throws IOException { // if (value instanceof StringValue) { // final StringValue sv = (StringValue) value; // stream.print(sv.getValueLength()); // stream.print(':'); // stream.write(sv.getValue()); // // } else if (value instanceof IntegerValue) { // final IntegerValue iv = (IntegerValue) value; // stream.print('i'); // stream.print(iv.getValue()); // stream.print('e'); // // } else if (value instanceof ListValue) { // final ListValue lv = (ListValue) value; // stream.print('l'); // for (final Value<?> val : lv.getValue()) { // writeValue(val); // } // stream.print('e'); // // } else if (value instanceof DictionaryValue) { // final DictionaryValue dv = (DictionaryValue) value; // stream.print('d'); // for (final Map.Entry<String,Value<?>> me : dv.getValue().entrySet()) { // writeValue(new StringValue(me.getKey())); // writeValue(me.getValue()); // } // stream.print('e'); // // } else { // throw new IllegalArgumentException("Invalid value type"); // } // } // // @Override // public void close () { // stream.close(); // } // // @Override // public void flush () { // stream.flush(); // } // } // // Path: src/es/darkhogg/torrent/bencode/Value.java // public abstract class Value<T> { // // /** // * Creates this object with the given initial value // * // * @param value Initial value // */ // /* package-private */Value (final T value) { // setValue(value); // } // // /** // * Gets the current value for this object // * // * @return This object value // */ // public abstract T getValue (); // // /** // * Sets a new value for this object // * // * @param value New value // */ // public abstract void setValue (T value); // // /** // * Returns the length, in bytes, this value will take up when encoded using UTF-8 as the encoding character set. // * <p> // * If the size cannot be determined accurately, an upper bound must be returned. // * // * @return The length of the encoded byte stream for this value // */ // public abstract long getEncodedLength (); // // } // Path: src/es/darkhogg/torrent/data/Sha1Hash.java import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import es.darkhogg.torrent.bencode.BencodeOutputStream; import es.darkhogg.torrent.bencode.Value; } /** * Returns the binary representation of this hash as an URL-encoded string * * @return An URL-encoded string representing this hash */ public String toUrlEncodedString () { return urlEncodedString; } /** * Returns a <tt>Sha1Hash</tt> object representing the SHA-1 hash of the given bencode <tt>Value</tt>. The passed * value is re-encoded, but only at most 64 bytes are buffered at any given time to compute the SHA-1 hash. * <p> * If the encoding fails for some reason or the SHA-1 algorithm is not available in this JVM, this method returns * <tt>null</tt>. * * @param value The value to hash * @return The hash of the <tt>value</tt> argument, or <tt>null</tt> if it cannot be calculated for some reason. */ public static Sha1Hash forValue (Value<?> value) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA1"); } catch (NoSuchAlgorithmException e) { // If the SHA1 algorithm doesn't exist, returns null return null; }
BencodeOutputStream bout = new BencodeOutputStream(new DigestOutputStream(new VoidOutputStream(), md));
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/MainActivity.java // public class MainActivity extends ActionBarActivity implements NavigationOwner.Activity { // // @Inject AuthInteractor authInteractor; // @Inject NavigationOwner navigationOwner; // @InjectView(R.id.container) ViewGroup container; // private ActivityComponent activityComponent; // private UserComponent userComponent; // private Subscription authSub; // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); // AppComponent appComponent = DaggerService.getAppComponent(getApplication()); // activityComponent = DaggerActivityComponent.builder().appComponent(appComponent).build(); // activityComponent.inject(this); // // appComponent.getActivitySubComponent(); // // ButterKnife.inject(this); // navigationOwner.takeActivity(this); // authSub = authInteractor.observeUserState().subscribe(new Action1<User>() { // @Override public void call(User user) { // if (user != null) { // userComponent = DaggerUserComponent.builder() // .activityComponent(activityComponent) // .userDataModule(new UserDataModule(authInteractor.credentials(), user)) // .build(); // } else { // userComponent = null; // } // } // }); // if (authInteractor.isLoggedIn()) { // showView(NavigationOwner.View.HOME); // } else { // showView(NavigationOwner.View.LOGIN); // } // } // // @Override public Object getSystemService(@NonNull String name) { // if (DaggerService.matchesUserInjectorService(name)) { // return userComponent; // } // if (DaggerService.matchesInjectorService(name)) { // return activityComponent; // } // return super.getSystemService(name); // } // // @Override public void showView(NavigationOwner.View view) { // Timber.d("To " + view); // container.removeAllViews(); // switch (view) { // case HOME: // getLayoutInflater().inflate(R.layout.home_view, container); // return; // case LOGIN: // getLayoutInflater().inflate(R.layout.login_view, container); // return; // default: // throw new IllegalStateException("Define this view: " + view + " within " + MainActivity.class.getSimpleName()); // } // } // // @Override protected void onDestroy() { // safeUnsubscribe(authSub); // navigationOwner.dropActivity(); // super.onDestroy(); // } // }
import android.app.Application; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import com.alexrwegener.dagger2byexamples.ui.MainActivity; import dagger.Component;
package com.alexrwegener.dagger2byexamples.di.activity; @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { void inject(MainActivity activity);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/MainActivity.java // public class MainActivity extends ActionBarActivity implements NavigationOwner.Activity { // // @Inject AuthInteractor authInteractor; // @Inject NavigationOwner navigationOwner; // @InjectView(R.id.container) ViewGroup container; // private ActivityComponent activityComponent; // private UserComponent userComponent; // private Subscription authSub; // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); // AppComponent appComponent = DaggerService.getAppComponent(getApplication()); // activityComponent = DaggerActivityComponent.builder().appComponent(appComponent).build(); // activityComponent.inject(this); // // appComponent.getActivitySubComponent(); // // ButterKnife.inject(this); // navigationOwner.takeActivity(this); // authSub = authInteractor.observeUserState().subscribe(new Action1<User>() { // @Override public void call(User user) { // if (user != null) { // userComponent = DaggerUserComponent.builder() // .activityComponent(activityComponent) // .userDataModule(new UserDataModule(authInteractor.credentials(), user)) // .build(); // } else { // userComponent = null; // } // } // }); // if (authInteractor.isLoggedIn()) { // showView(NavigationOwner.View.HOME); // } else { // showView(NavigationOwner.View.LOGIN); // } // } // // @Override public Object getSystemService(@NonNull String name) { // if (DaggerService.matchesUserInjectorService(name)) { // return userComponent; // } // if (DaggerService.matchesInjectorService(name)) { // return activityComponent; // } // return super.getSystemService(name); // } // // @Override public void showView(NavigationOwner.View view) { // Timber.d("To " + view); // container.removeAllViews(); // switch (view) { // case HOME: // getLayoutInflater().inflate(R.layout.home_view, container); // return; // case LOGIN: // getLayoutInflater().inflate(R.layout.login_view, container); // return; // default: // throw new IllegalStateException("Define this view: " + view + " within " + MainActivity.class.getSimpleName()); // } // } // // @Override protected void onDestroy() { // safeUnsubscribe(authSub); // navigationOwner.dropActivity(); // super.onDestroy(); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java import android.app.Application; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import com.alexrwegener.dagger2byexamples.ui.MainActivity; import dagger.Component; package com.alexrwegener.dagger2byexamples.di.activity; @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { void inject(MainActivity activity);
AuthInteractor authInteractor();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/MainActivity.java // public class MainActivity extends ActionBarActivity implements NavigationOwner.Activity { // // @Inject AuthInteractor authInteractor; // @Inject NavigationOwner navigationOwner; // @InjectView(R.id.container) ViewGroup container; // private ActivityComponent activityComponent; // private UserComponent userComponent; // private Subscription authSub; // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); // AppComponent appComponent = DaggerService.getAppComponent(getApplication()); // activityComponent = DaggerActivityComponent.builder().appComponent(appComponent).build(); // activityComponent.inject(this); // // appComponent.getActivitySubComponent(); // // ButterKnife.inject(this); // navigationOwner.takeActivity(this); // authSub = authInteractor.observeUserState().subscribe(new Action1<User>() { // @Override public void call(User user) { // if (user != null) { // userComponent = DaggerUserComponent.builder() // .activityComponent(activityComponent) // .userDataModule(new UserDataModule(authInteractor.credentials(), user)) // .build(); // } else { // userComponent = null; // } // } // }); // if (authInteractor.isLoggedIn()) { // showView(NavigationOwner.View.HOME); // } else { // showView(NavigationOwner.View.LOGIN); // } // } // // @Override public Object getSystemService(@NonNull String name) { // if (DaggerService.matchesUserInjectorService(name)) { // return userComponent; // } // if (DaggerService.matchesInjectorService(name)) { // return activityComponent; // } // return super.getSystemService(name); // } // // @Override public void showView(NavigationOwner.View view) { // Timber.d("To " + view); // container.removeAllViews(); // switch (view) { // case HOME: // getLayoutInflater().inflate(R.layout.home_view, container); // return; // case LOGIN: // getLayoutInflater().inflate(R.layout.login_view, container); // return; // default: // throw new IllegalStateException("Define this view: " + view + " within " + MainActivity.class.getSimpleName()); // } // } // // @Override protected void onDestroy() { // safeUnsubscribe(authSub); // navigationOwner.dropActivity(); // super.onDestroy(); // } // }
import android.app.Application; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import com.alexrwegener.dagger2byexamples.ui.MainActivity; import dagger.Component;
package com.alexrwegener.dagger2byexamples.di.activity; @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { void inject(MainActivity activity); AuthInteractor authInteractor();
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/MainActivity.java // public class MainActivity extends ActionBarActivity implements NavigationOwner.Activity { // // @Inject AuthInteractor authInteractor; // @Inject NavigationOwner navigationOwner; // @InjectView(R.id.container) ViewGroup container; // private ActivityComponent activityComponent; // private UserComponent userComponent; // private Subscription authSub; // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); // AppComponent appComponent = DaggerService.getAppComponent(getApplication()); // activityComponent = DaggerActivityComponent.builder().appComponent(appComponent).build(); // activityComponent.inject(this); // // appComponent.getActivitySubComponent(); // // ButterKnife.inject(this); // navigationOwner.takeActivity(this); // authSub = authInteractor.observeUserState().subscribe(new Action1<User>() { // @Override public void call(User user) { // if (user != null) { // userComponent = DaggerUserComponent.builder() // .activityComponent(activityComponent) // .userDataModule(new UserDataModule(authInteractor.credentials(), user)) // .build(); // } else { // userComponent = null; // } // } // }); // if (authInteractor.isLoggedIn()) { // showView(NavigationOwner.View.HOME); // } else { // showView(NavigationOwner.View.LOGIN); // } // } // // @Override public Object getSystemService(@NonNull String name) { // if (DaggerService.matchesUserInjectorService(name)) { // return userComponent; // } // if (DaggerService.matchesInjectorService(name)) { // return activityComponent; // } // return super.getSystemService(name); // } // // @Override public void showView(NavigationOwner.View view) { // Timber.d("To " + view); // container.removeAllViews(); // switch (view) { // case HOME: // getLayoutInflater().inflate(R.layout.home_view, container); // return; // case LOGIN: // getLayoutInflater().inflate(R.layout.login_view, container); // return; // default: // throw new IllegalStateException("Define this view: " + view + " within " + MainActivity.class.getSimpleName()); // } // } // // @Override protected void onDestroy() { // safeUnsubscribe(authSub); // navigationOwner.dropActivity(); // super.onDestroy(); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java import android.app.Application; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import com.alexrwegener.dagger2byexamples.ui.MainActivity; import dagger.Component; package com.alexrwegener.dagger2byexamples.di.activity; @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { void inject(MainActivity activity); AuthInteractor authInteractor();
NavigationOwner navigationOwner();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // }
import com.alexrwegener.dagger2byexamples.data.user.User; import rx.Observable;
package com.alexrwegener.dagger2byexamples.interactor.auth; public interface AuthInteractor { Observable<Boolean> authenticate(String username); boolean isLoggedIn(); String credentials();
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java import com.alexrwegener.dagger2byexamples.data.user.User; import rx.Observable; package com.alexrwegener.dagger2byexamples.interactor.auth; public interface AuthInteractor { Observable<Boolean> authenticate(String username); boolean isLoggedIn(); String credentials();
Observable<User> observeUserState();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginPresenter.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/util/Prescriptions.java // public static void safeUnsubscribe(Subscription subscription) { // if (subscription != null && !subscription.isUnsubscribed()) { // subscription.unsubscribe(); // } // }
import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import javax.inject.Inject; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import rx.schedulers.Schedulers; import timber.log.Timber; import static com.alexrwegener.dagger2byexamples.util.Prescriptions.safeUnsubscribe;
package com.alexrwegener.dagger2byexamples.ui.login; public final class LoginPresenter { private final AuthInteractor authInteractor;
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/util/Prescriptions.java // public static void safeUnsubscribe(Subscription subscription) { // if (subscription != null && !subscription.isUnsubscribed()) { // subscription.unsubscribe(); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginPresenter.java import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import javax.inject.Inject; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import rx.schedulers.Schedulers; import timber.log.Timber; import static com.alexrwegener.dagger2byexamples.util.Prescriptions.safeUnsubscribe; package com.alexrwegener.dagger2byexamples.ui.login; public final class LoginPresenter { private final AuthInteractor authInteractor;
private final NavigationOwner navigationOwner;
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginPresenter.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/util/Prescriptions.java // public static void safeUnsubscribe(Subscription subscription) { // if (subscription != null && !subscription.isUnsubscribed()) { // subscription.unsubscribe(); // } // }
import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import javax.inject.Inject; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import rx.schedulers.Schedulers; import timber.log.Timber; import static com.alexrwegener.dagger2byexamples.util.Prescriptions.safeUnsubscribe;
package com.alexrwegener.dagger2byexamples.ui.login; public final class LoginPresenter { private final AuthInteractor authInteractor; private final NavigationOwner navigationOwner; private Subscription authSub; private LoginView loginView; @Inject LoginPresenter(AuthInteractor authInteractor, NavigationOwner navigationOwner) { this.authInteractor = authInteractor; this.navigationOwner = navigationOwner; } void takeView(LoginView view) { loginView = view; } void dropView() {
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/util/Prescriptions.java // public static void safeUnsubscribe(Subscription subscription) { // if (subscription != null && !subscription.isUnsubscribed()) { // subscription.unsubscribe(); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginPresenter.java import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import javax.inject.Inject; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import rx.schedulers.Schedulers; import timber.log.Timber; import static com.alexrwegener.dagger2byexamples.util.Prescriptions.safeUnsubscribe; package com.alexrwegener.dagger2byexamples.ui.login; public final class LoginPresenter { private final AuthInteractor authInteractor; private final NavigationOwner navigationOwner; private Subscription authSub; private LoginView loginView; @Inject LoginPresenter(AuthInteractor authInteractor, NavigationOwner navigationOwner) { this.authInteractor = authInteractor; this.navigationOwner = navigationOwner; } void takeView(LoginView view) { loginView = view; } void dropView() {
safeUnsubscribe(authSub);
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // }
import com.alexrwegener.dagger2byexamples.di.ScreenScope; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component;
package com.alexrwegener.dagger2byexamples.ui.home; @ScreenScope(HomeComponent.class) @Component(dependencies = UserComponent.class) interface HomeComponent { void inject(HomeView view);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeComponent.java import com.alexrwegener.dagger2byexamples.di.ScreenScope; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component; package com.alexrwegener.dagger2byexamples.ui.home; @ScreenScope(HomeComponent.class) @Component(dependencies = UserComponent.class) interface HomeComponent { void inject(HomeView view);
NavigationOwner owner();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // }
import com.alexrwegener.dagger2byexamples.di.ScreenScope; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component;
package com.alexrwegener.dagger2byexamples.ui.home; @ScreenScope(HomeComponent.class) @Component(dependencies = UserComponent.class) interface HomeComponent { void inject(HomeView view); NavigationOwner owner();
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeComponent.java import com.alexrwegener.dagger2byexamples.di.ScreenScope; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component; package com.alexrwegener.dagger2byexamples.ui.home; @ScreenScope(HomeComponent.class) @Component(dependencies = UserComponent.class) interface HomeComponent { void inject(HomeView view); NavigationOwner owner();
UserInteractor userInteractor();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/store/app/RealAppStore.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/util/Strings.java // public static boolean isBlank(final CharSequence cs) { // int strLen; // if (cs == null || (strLen = cs.length()) == 0) { // return true; // } // for (int i = 0; i < strLen; i++) { // if (!Character.isWhitespace(cs.charAt(i))) { // return false; // } // } // return true; // }
import static com.alexrwegener.dagger2byexamples.util.Strings.isBlank;
package com.alexrwegener.dagger2byexamples.store.app; final class RealAppStore implements AppStore { private String username; @Override public boolean isLoggedIn() {
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/util/Strings.java // public static boolean isBlank(final CharSequence cs) { // int strLen; // if (cs == null || (strLen = cs.length()) == 0) { // return true; // } // for (int i = 0; i < strLen; i++) { // if (!Character.isWhitespace(cs.charAt(i))) { // return false; // } // } // return true; // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/app/RealAppStore.java import static com.alexrwegener.dagger2byexamples.util.Strings.isBlank; package com.alexrwegener.dagger2byexamples.store.app; final class RealAppStore implements AppStore { private String username; @Override public boolean isLoggedIn() {
return !isBlank(username);
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // }
import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component;
package com.alexrwegener.dagger2byexamples.di.user; @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { NavigationOwner navigationOwner();
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component; package com.alexrwegener.dagger2byexamples.di.user; @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { NavigationOwner navigationOwner();
UserInteractor userInteractor();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/App.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // }
import android.app.Application; import android.support.annotation.NonNull; import com.alexrwegener.dagger2byexamples.di.DaggerService; import timber.log.Timber;
package com.alexrwegener.dagger2byexamples; public class App extends Application { private AppComponent component; @Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } Timber.d("Initializing App"); component = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); } @Override public Object getSystemService(@NonNull String name) {
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/App.java import android.app.Application; import android.support.annotation.NonNull; import com.alexrwegener.dagger2byexamples.di.DaggerService; import timber.log.Timber; package com.alexrwegener.dagger2byexamples; public class App extends Application { private AppComponent component; @Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } Timber.d("Initializing App"); component = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); } @Override public Object getSystemService(@NonNull String name) {
if (DaggerService.matchesInjectorService(name)) {
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginView.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // }
import android.content.Context; import android.util.AttributeSet; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import javax.inject.Inject;
package com.alexrwegener.dagger2byexamples.ui.login; public class LoginView extends LinearLayout { @Inject LoginPresenter presenter; @InjectView(R.id.login_username) EditText emailInput; @InjectView(R.id.login_button) Button loginButton; public LoginView(Context context, AttributeSet attrs) { super(context, attrs);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginView.java import android.content.Context; import android.util.AttributeSet; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import javax.inject.Inject; package com.alexrwegener.dagger2byexamples.ui.login; public class LoginView extends LinearLayout { @Inject LoginPresenter presenter; @InjectView(R.id.login_username) EditText emailInput; @InjectView(R.id.login_button) Button loginButton; public LoginView(Context context, AttributeSet attrs) { super(context, attrs);
ActivityComponent activityComponent = DaggerService.getActivityComponent(context);
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginView.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // }
import android.content.Context; import android.util.AttributeSet; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import javax.inject.Inject;
package com.alexrwegener.dagger2byexamples.ui.login; public class LoginView extends LinearLayout { @Inject LoginPresenter presenter; @InjectView(R.id.login_username) EditText emailInput; @InjectView(R.id.login_button) Button loginButton; public LoginView(Context context, AttributeSet attrs) { super(context, attrs);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginView.java import android.content.Context; import android.util.AttributeSet; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import javax.inject.Inject; package com.alexrwegener.dagger2byexamples.ui.login; public class LoginView extends LinearLayout { @Inject LoginPresenter presenter; @InjectView(R.id.login_username) EditText emailInput; @InjectView(R.id.login_button) Button loginButton; public LoginView(Context context, AttributeSet attrs) { super(context, attrs);
ActivityComponent activityComponent = DaggerService.getActivityComponent(context);
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // }
import android.app.Application; import com.alexrwegener.dagger2byexamples.di.ApplicationScope; import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import dagger.Component;
package com.alexrwegener.dagger2byexamples; @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { Application application();
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/AuthInteractor.java // public interface AuthInteractor { // Observable<Boolean> authenticate(String username); // // boolean isLoggedIn(); // // String credentials(); // // Observable<User> observeUserState(); // // Observable<Boolean> logout(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java import android.app.Application; import com.alexrwegener.dagger2byexamples.di.ApplicationScope; import com.alexrwegener.dagger2byexamples.interactor.auth.AuthInteractor; import dagger.Component; package com.alexrwegener.dagger2byexamples; @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { Application application();
AuthInteractor authInteractor();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeView.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // }
import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnCheckedChanged; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import javax.inject.Inject;
package com.alexrwegener.dagger2byexamples.ui.home; public class HomeView extends LinearLayout { @Inject HomePresenter presenter; @InjectView(R.id.home_first_name) TextView firstName; @InjectView(R.id.home_last_name) TextView lastName; @InjectView(R.id.home_enjoys_scopes) Switch enjoysScopesSwitch; public HomeView(Context context, AttributeSet attrs) { super(context, attrs);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeView.java import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnCheckedChanged; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import javax.inject.Inject; package com.alexrwegener.dagger2byexamples.ui.home; public class HomeView extends LinearLayout { @Inject HomePresenter presenter; @InjectView(R.id.home_first_name) TextView firstName; @InjectView(R.id.home_last_name) TextView lastName; @InjectView(R.id.home_enjoys_scopes) Switch enjoysScopesSwitch; public HomeView(Context context, AttributeSet attrs) { super(context, attrs);
UserComponent userComponent = DaggerService.getUserComponent(context);
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeView.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // }
import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnCheckedChanged; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import javax.inject.Inject;
package com.alexrwegener.dagger2byexamples.ui.home; public class HomeView extends LinearLayout { @Inject HomePresenter presenter; @InjectView(R.id.home_first_name) TextView firstName; @InjectView(R.id.home_last_name) TextView lastName; @InjectView(R.id.home_enjoys_scopes) Switch enjoysScopesSwitch; public HomeView(Context context, AttributeSet attrs) { super(context, attrs);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeView.java import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnCheckedChanged; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import javax.inject.Inject; package com.alexrwegener.dagger2byexamples.ui.home; public class HomeView extends LinearLayout { @Inject HomePresenter presenter; @InjectView(R.id.home_first_name) TextView firstName; @InjectView(R.id.home_last_name) TextView lastName; @InjectView(R.id.home_enjoys_scopes) Switch enjoysScopesSwitch; public HomeView(Context context, AttributeSet attrs) { super(context, attrs);
UserComponent userComponent = DaggerService.getUserComponent(context);
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeView.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // }
import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnCheckedChanged; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import javax.inject.Inject;
package com.alexrwegener.dagger2byexamples.ui.home; public class HomeView extends LinearLayout { @Inject HomePresenter presenter; @InjectView(R.id.home_first_name) TextView firstName; @InjectView(R.id.home_last_name) TextView lastName; @InjectView(R.id.home_enjoys_scopes) Switch enjoysScopesSwitch; public HomeView(Context context, AttributeSet attrs) { super(context, attrs); UserComponent userComponent = DaggerService.getUserComponent(context); HomeComponent homeComponent = DaggerHomeComponent.builder().userComponent(userComponent).build(); homeComponent.inject(this); } @Override protected void onFinishInflate() { super.onFinishInflate(); ButterKnife.inject(this); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); presenter.takeView(this); } @Override protected void onDetachedFromWindow() { presenter.dropView(); super.onDetachedFromWindow(); }
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java // public final class DaggerService { // private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; // private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; // // private DaggerService() { // throw new AssertionError("No instances"); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static AppComponent getAppComponent(Context applicationContext) { // return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static ActivityComponent getActivityComponent(Context activityContext) { // return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); // } // // @SuppressWarnings("ResourceType") // Explicitly doing a custom service. // public static UserComponent getUserComponent(Context activityContext) { // return (UserComponent) activityContext.getSystemService(USER_INJECTOR_SERVICE); // } // // public static boolean matchesUserInjectorService(String name) { // return USER_INJECTOR_SERVICE.equals(name); // } // // public static boolean matchesInjectorService(String name) { // return INJECTOR_SERVICE.equals(name); // } // // //Unused. Example of how to use reflection to bypass SomeComponent.builder().blah(new Blah("hi")).build() // public static <T> T createComponent(Class<T> componentClass, Object... dependencies) { // String fqn = componentClass.getName(); // String packageName = componentClass.getPackage().getName(); // // Accounts for inner classes, ie MyApplication$Component // String simpleName = fqn.substring(packageName.length() + 1); // String generatedName = (packageName + ".Dagger" + simpleName).replace('$', '_'); // try { // Class<?> generatedClass = Class.forName(generatedName); // Object builder = generatedClass.getMethod("builder").invoke(null); // for (Method method : builder.getClass().getMethods()) { // Class<?>[] params = method.getParameterTypes(); // if (params.length == 1) { // Class<?> dependencyClass = params[0]; // for (Object dependency : dependencies) { // if (dependencyClass.isAssignableFrom(dependency.getClass())) { // method.invoke(builder, dependency); // break; // } // } // } // } // //noinspection unchecked // return (T) builder.getClass().getMethod("build").invoke(builder); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomeView.java import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnCheckedChanged; import butterknife.OnClick; import com.alexrwegener.dagger2byexamples.R; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.di.DaggerService; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import javax.inject.Inject; package com.alexrwegener.dagger2byexamples.ui.home; public class HomeView extends LinearLayout { @Inject HomePresenter presenter; @InjectView(R.id.home_first_name) TextView firstName; @InjectView(R.id.home_last_name) TextView lastName; @InjectView(R.id.home_enjoys_scopes) Switch enjoysScopesSwitch; public HomeView(Context context, AttributeSet attrs) { super(context, attrs); UserComponent userComponent = DaggerService.getUserComponent(context); HomeComponent homeComponent = DaggerHomeComponent.builder().userComponent(userComponent).build(); homeComponent.inject(this); } @Override protected void onFinishInflate() { super.onFinishInflate(); ButterKnife.inject(this); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); presenter.takeView(this); } @Override protected void onDetachedFromWindow() { presenter.dropView(); super.onDetachedFromWindow(); }
void loadUser(User user, boolean enjoysScopes) {
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginComponent.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // }
import com.alexrwegener.dagger2byexamples.di.ScreenScope; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component;
package com.alexrwegener.dagger2byexamples.ui.login; @ScreenScope(LoginComponent.class) @Component(dependencies = ActivityComponent.class) public interface LoginComponent { void inject(LoginView view);
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/login/LoginComponent.java import com.alexrwegener.dagger2byexamples.di.ScreenScope; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import dagger.Component; package com.alexrwegener.dagger2byexamples.ui.login; @ScreenScope(LoginComponent.class) @Component(dependencies = ActivityComponent.class) public interface LoginComponent { void inject(LoginView view);
NavigationOwner navigationOwner();
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/RealAuthInteractor.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/api/auth/AuthService.java // public interface AuthService { // @POST("/auth") Observable<User> authenticate(@Body String username); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/app/AppStore.java // public interface AppStore { // boolean isLoggedIn(); // // void saveCredentials(String username); // // String getCredentials(); // }
import com.alexrwegener.dagger2byexamples.api.auth.AuthService; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.store.app.AppStore; import rx.Observable; import rx.functions.Action1; import rx.functions.Func1; import rx.subjects.BehaviorSubject;
package com.alexrwegener.dagger2byexamples.interactor.auth; public class RealAuthInteractor implements AuthInteractor { private final BehaviorSubject<User> authSubject;
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/api/auth/AuthService.java // public interface AuthService { // @POST("/auth") Observable<User> authenticate(@Body String username); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/app/AppStore.java // public interface AppStore { // boolean isLoggedIn(); // // void saveCredentials(String username); // // String getCredentials(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/RealAuthInteractor.java import com.alexrwegener.dagger2byexamples.api.auth.AuthService; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.store.app.AppStore; import rx.Observable; import rx.functions.Action1; import rx.functions.Func1; import rx.subjects.BehaviorSubject; package com.alexrwegener.dagger2byexamples.interactor.auth; public class RealAuthInteractor implements AuthInteractor { private final BehaviorSubject<User> authSubject;
private final AuthService authService;
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/RealAuthInteractor.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/api/auth/AuthService.java // public interface AuthService { // @POST("/auth") Observable<User> authenticate(@Body String username); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/app/AppStore.java // public interface AppStore { // boolean isLoggedIn(); // // void saveCredentials(String username); // // String getCredentials(); // }
import com.alexrwegener.dagger2byexamples.api.auth.AuthService; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.store.app.AppStore; import rx.Observable; import rx.functions.Action1; import rx.functions.Func1; import rx.subjects.BehaviorSubject;
package com.alexrwegener.dagger2byexamples.interactor.auth; public class RealAuthInteractor implements AuthInteractor { private final BehaviorSubject<User> authSubject; private final AuthService authService;
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/api/auth/AuthService.java // public interface AuthService { // @POST("/auth") Observable<User> authenticate(@Body String username); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/app/AppStore.java // public interface AppStore { // boolean isLoggedIn(); // // void saveCredentials(String username); // // String getCredentials(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/auth/RealAuthInteractor.java import com.alexrwegener.dagger2byexamples.api.auth.AuthService; import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.store.app.AppStore; import rx.Observable; import rx.functions.Action1; import rx.functions.Func1; import rx.subjects.BehaviorSubject; package com.alexrwegener.dagger2byexamples.interactor.auth; public class RealAuthInteractor implements AuthInteractor { private final BehaviorSubject<User> authSubject; private final AuthService authService;
private final AppStore appStore;
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/RealUserInteractor.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/UserStore.java // public interface UserStore { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // }
import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.store.user.UserStore;
package com.alexrwegener.dagger2byexamples.interactor.user; public class RealUserInteractor implements UserInteractor { private final UserStore userStore; RealUserInteractor(UserStore userStore) { this.userStore = userStore; }
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/UserStore.java // public interface UserStore { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/RealUserInteractor.java import com.alexrwegener.dagger2byexamples.data.user.User; import com.alexrwegener.dagger2byexamples.store.user.UserStore; package com.alexrwegener.dagger2byexamples.interactor.user; public class RealUserInteractor implements UserInteractor { private final UserStore userStore; RealUserInteractor(UserStore userStore) { this.userStore = userStore; }
@Override public User user() {
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomePresenter.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // }
import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import javax.inject.Inject;
package com.alexrwegener.dagger2byexamples.ui.home; public final class HomePresenter { private final UserInteractor userInteractor;
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/interactor/user/UserInteractor.java // public interface UserInteractor { // User user(); // // boolean isEnjoyingScopes(); // // void isEnjoyingScopes(boolean isEnjoying); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/owner/navigation/NavigationOwner.java // public final class NavigationOwner { // // private Activity activity; // // public void takeActivity(Activity activity) { // this.activity = activity; // } // // public void dropActivity() { // activity = null; // } // // public void showView(View view) { // if (activity != null) { // activity.showView(view); // } else { // Timber.e(Activity.class.getSimpleName() + " is null"); // } // } // // public enum View { // LOGIN(R.id.login_button), HOME(R.layout.home_view); // // private int layoutId; // // View(int layoutId) { // this.layoutId = layoutId; // } // } // // public interface Activity { // void showView(View view); // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/ui/home/HomePresenter.java import com.alexrwegener.dagger2byexamples.interactor.user.UserInteractor; import com.alexrwegener.dagger2byexamples.owner.navigation.NavigationOwner; import javax.inject.Inject; package com.alexrwegener.dagger2byexamples.ui.home; public final class HomePresenter { private final UserInteractor userInteractor;
private final NavigationOwner navigationOwner;
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/RealUserStore.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/BooleanPreference.java // public final class BooleanPreference { // private final SharedPreferences preferences; // private final String key; // private final boolean defaultValue; // // public BooleanPreference(SharedPreferences preferences, String key) { // this(preferences, key, false); // } // // public BooleanPreference(SharedPreferences preferences, String key, boolean defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public boolean get() { // return preferences.getBoolean(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(boolean value) { // preferences.edit().putBoolean(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putBoolean(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == defaultValue; // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/StringPreference.java // public final class StringPreference { // private final SharedPreferences preferences; // private final String key; // private final String defaultValue; // // public StringPreference(SharedPreferences preferences, String key) { // this(preferences, key, null); // } // // public StringPreference(SharedPreferences preferences, String key, String defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public String get() { // return preferences.getString(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(String value) { // preferences.edit().putString(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putString(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == null && defaultValue == null || get().equals(defaultValue); // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // }
import android.content.SharedPreferences; import com.alexrwegener.dagger2byexamples.android.preferences.BooleanPreference; import com.alexrwegener.dagger2byexamples.android.preferences.StringPreference; import com.alexrwegener.dagger2byexamples.data.user.User;
package com.alexrwegener.dagger2byexamples.store.user; final class RealUserStore implements UserStore { private static final String FIRST_NAME = "first_name"; private static final String LAST_NAME = "last_name"; private static final String ENJOYS_SCOPES = "enjoys_scopes";
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/BooleanPreference.java // public final class BooleanPreference { // private final SharedPreferences preferences; // private final String key; // private final boolean defaultValue; // // public BooleanPreference(SharedPreferences preferences, String key) { // this(preferences, key, false); // } // // public BooleanPreference(SharedPreferences preferences, String key, boolean defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public boolean get() { // return preferences.getBoolean(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(boolean value) { // preferences.edit().putBoolean(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putBoolean(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == defaultValue; // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/StringPreference.java // public final class StringPreference { // private final SharedPreferences preferences; // private final String key; // private final String defaultValue; // // public StringPreference(SharedPreferences preferences, String key) { // this(preferences, key, null); // } // // public StringPreference(SharedPreferences preferences, String key, String defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public String get() { // return preferences.getString(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(String value) { // preferences.edit().putString(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putString(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == null && defaultValue == null || get().equals(defaultValue); // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/RealUserStore.java import android.content.SharedPreferences; import com.alexrwegener.dagger2byexamples.android.preferences.BooleanPreference; import com.alexrwegener.dagger2byexamples.android.preferences.StringPreference; import com.alexrwegener.dagger2byexamples.data.user.User; package com.alexrwegener.dagger2byexamples.store.user; final class RealUserStore implements UserStore { private static final String FIRST_NAME = "first_name"; private static final String LAST_NAME = "last_name"; private static final String ENJOYS_SCOPES = "enjoys_scopes";
private final StringPreference firstName;
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/RealUserStore.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/BooleanPreference.java // public final class BooleanPreference { // private final SharedPreferences preferences; // private final String key; // private final boolean defaultValue; // // public BooleanPreference(SharedPreferences preferences, String key) { // this(preferences, key, false); // } // // public BooleanPreference(SharedPreferences preferences, String key, boolean defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public boolean get() { // return preferences.getBoolean(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(boolean value) { // preferences.edit().putBoolean(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putBoolean(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == defaultValue; // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/StringPreference.java // public final class StringPreference { // private final SharedPreferences preferences; // private final String key; // private final String defaultValue; // // public StringPreference(SharedPreferences preferences, String key) { // this(preferences, key, null); // } // // public StringPreference(SharedPreferences preferences, String key, String defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public String get() { // return preferences.getString(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(String value) { // preferences.edit().putString(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putString(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == null && defaultValue == null || get().equals(defaultValue); // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // }
import android.content.SharedPreferences; import com.alexrwegener.dagger2byexamples.android.preferences.BooleanPreference; import com.alexrwegener.dagger2byexamples.android.preferences.StringPreference; import com.alexrwegener.dagger2byexamples.data.user.User;
package com.alexrwegener.dagger2byexamples.store.user; final class RealUserStore implements UserStore { private static final String FIRST_NAME = "first_name"; private static final String LAST_NAME = "last_name"; private static final String ENJOYS_SCOPES = "enjoys_scopes"; private final StringPreference firstName; private final StringPreference lastName;
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/BooleanPreference.java // public final class BooleanPreference { // private final SharedPreferences preferences; // private final String key; // private final boolean defaultValue; // // public BooleanPreference(SharedPreferences preferences, String key) { // this(preferences, key, false); // } // // public BooleanPreference(SharedPreferences preferences, String key, boolean defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public boolean get() { // return preferences.getBoolean(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(boolean value) { // preferences.edit().putBoolean(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putBoolean(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == defaultValue; // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/StringPreference.java // public final class StringPreference { // private final SharedPreferences preferences; // private final String key; // private final String defaultValue; // // public StringPreference(SharedPreferences preferences, String key) { // this(preferences, key, null); // } // // public StringPreference(SharedPreferences preferences, String key, String defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public String get() { // return preferences.getString(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(String value) { // preferences.edit().putString(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putString(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == null && defaultValue == null || get().equals(defaultValue); // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/RealUserStore.java import android.content.SharedPreferences; import com.alexrwegener.dagger2byexamples.android.preferences.BooleanPreference; import com.alexrwegener.dagger2byexamples.android.preferences.StringPreference; import com.alexrwegener.dagger2byexamples.data.user.User; package com.alexrwegener.dagger2byexamples.store.user; final class RealUserStore implements UserStore { private static final String FIRST_NAME = "first_name"; private static final String LAST_NAME = "last_name"; private static final String ENJOYS_SCOPES = "enjoys_scopes"; private final StringPreference firstName; private final StringPreference lastName;
private final BooleanPreference enjoysScopes;
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/RealUserStore.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/BooleanPreference.java // public final class BooleanPreference { // private final SharedPreferences preferences; // private final String key; // private final boolean defaultValue; // // public BooleanPreference(SharedPreferences preferences, String key) { // this(preferences, key, false); // } // // public BooleanPreference(SharedPreferences preferences, String key, boolean defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public boolean get() { // return preferences.getBoolean(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(boolean value) { // preferences.edit().putBoolean(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putBoolean(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == defaultValue; // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/StringPreference.java // public final class StringPreference { // private final SharedPreferences preferences; // private final String key; // private final String defaultValue; // // public StringPreference(SharedPreferences preferences, String key) { // this(preferences, key, null); // } // // public StringPreference(SharedPreferences preferences, String key, String defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public String get() { // return preferences.getString(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(String value) { // preferences.edit().putString(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putString(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == null && defaultValue == null || get().equals(defaultValue); // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // }
import android.content.SharedPreferences; import com.alexrwegener.dagger2byexamples.android.preferences.BooleanPreference; import com.alexrwegener.dagger2byexamples.android.preferences.StringPreference; import com.alexrwegener.dagger2byexamples.data.user.User;
package com.alexrwegener.dagger2byexamples.store.user; final class RealUserStore implements UserStore { private static final String FIRST_NAME = "first_name"; private static final String LAST_NAME = "last_name"; private static final String ENJOYS_SCOPES = "enjoys_scopes"; private final StringPreference firstName; private final StringPreference lastName; private final BooleanPreference enjoysScopes;
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/BooleanPreference.java // public final class BooleanPreference { // private final SharedPreferences preferences; // private final String key; // private final boolean defaultValue; // // public BooleanPreference(SharedPreferences preferences, String key) { // this(preferences, key, false); // } // // public BooleanPreference(SharedPreferences preferences, String key, boolean defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public boolean get() { // return preferences.getBoolean(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(boolean value) { // preferences.edit().putBoolean(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putBoolean(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == defaultValue; // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/android/preferences/StringPreference.java // public final class StringPreference { // private final SharedPreferences preferences; // private final String key; // private final String defaultValue; // // public StringPreference(SharedPreferences preferences, String key) { // this(preferences, key, null); // } // // public StringPreference(SharedPreferences preferences, String key, String defaultValue) { // this.preferences = preferences; // this.key = key; // this.defaultValue = defaultValue; // } // // public String get() { // return preferences.getString(key, defaultValue); // } // // public boolean isSet() { // return preferences.contains(key); // } // // public void set(String value) { // preferences.edit().putString(key, value).apply(); // } // // public void delete() { // preferences.edit().remove(key).apply(); // } // // public void reset() { // preferences.edit().putString(key, defaultValue).apply(); // } // // public boolean isDefault() { // return get() == null && defaultValue == null || get().equals(defaultValue); // } // // public String key() { // return key; // } // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/data/user/User.java // public final class User { // public final String firstName; // public final String lastName; // // public User(String firstName, String lastName) { // this.firstName = firstName; // this.lastName = lastName; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // User user = (User) o; // // if (!firstName.equals(user.firstName)) return false; // return lastName.equals(user.lastName); // } // // @Override public int hashCode() { // int result = firstName.hashCode(); // result = 31 * result + lastName.hashCode(); // return result; // } // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/store/user/RealUserStore.java import android.content.SharedPreferences; import com.alexrwegener.dagger2byexamples.android.preferences.BooleanPreference; import com.alexrwegener.dagger2byexamples.android.preferences.StringPreference; import com.alexrwegener.dagger2byexamples.data.user.User; package com.alexrwegener.dagger2byexamples.store.user; final class RealUserStore implements UserStore { private static final String FIRST_NAME = "first_name"; private static final String LAST_NAME = "last_name"; private static final String ENJOYS_SCOPES = "enjoys_scopes"; private final StringPreference firstName; private final StringPreference lastName; private final BooleanPreference enjoysScopes;
RealUserStore(SharedPreferences sharedPreferences, User user) {
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // }
import android.content.Context; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import java.lang.reflect.Method;
package com.alexrwegener.dagger2byexamples.di; public final class DaggerService { private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; private DaggerService() { throw new AssertionError("No instances"); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service.
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java import android.content.Context; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import java.lang.reflect.Method; package com.alexrwegener.dagger2byexamples.di; public final class DaggerService { private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; private DaggerService() { throw new AssertionError("No instances"); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service.
public static AppComponent getAppComponent(Context applicationContext) {
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // }
import android.content.Context; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import java.lang.reflect.Method;
package com.alexrwegener.dagger2byexamples.di; public final class DaggerService { private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; private DaggerService() { throw new AssertionError("No instances"); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service. public static AppComponent getAppComponent(Context applicationContext) { return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service.
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java import android.content.Context; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import java.lang.reflect.Method; package com.alexrwegener.dagger2byexamples.di; public final class DaggerService { private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; private DaggerService() { throw new AssertionError("No instances"); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service. public static AppComponent getAppComponent(Context applicationContext) { return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service.
public static ActivityComponent getActivityComponent(Context activityContext) {
alexrwegener/dagger2-scopes
app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // }
import android.content.Context; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import java.lang.reflect.Method;
package com.alexrwegener.dagger2byexamples.di; public final class DaggerService { private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; private DaggerService() { throw new AssertionError("No instances"); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service. public static AppComponent getAppComponent(Context applicationContext) { return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service. public static ActivityComponent getActivityComponent(Context activityContext) { return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service.
// Path: app/src/main/java/com/alexrwegener/dagger2byexamples/AppComponent.java // @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent { // Application application(); // // AuthInteractor authInteractor(); // // ActivitySubComponent getActivitySubComponent(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/activity/ActivityComponent.java // @ActivityScope @Component(dependencies = AppComponent.class, modules = ActivityModule.class) public interface ActivityComponent { // // void inject(MainActivity activity); // // AuthInteractor authInteractor(); // // NavigationOwner navigationOwner(); // // Application application(); // } // // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/user/UserComponent.java // @UserScope @Component(dependencies = ActivityComponent.class, modules = UserModule.class) public interface UserComponent { // // NavigationOwner navigationOwner(); // // UserInteractor userInteractor(); // } // Path: app/src/main/java/com/alexrwegener/dagger2byexamples/di/DaggerService.java import android.content.Context; import com.alexrwegener.dagger2byexamples.AppComponent; import com.alexrwegener.dagger2byexamples.di.activity.ActivityComponent; import com.alexrwegener.dagger2byexamples.di.user.UserComponent; import java.lang.reflect.Method; package com.alexrwegener.dagger2byexamples.di; public final class DaggerService { private static final String INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector"; private static final String USER_INJECTOR_SERVICE = "com.alexrwegener.dagger2byexamples.injector.user"; private DaggerService() { throw new AssertionError("No instances"); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service. public static AppComponent getAppComponent(Context applicationContext) { return (AppComponent) applicationContext.getSystemService(INJECTOR_SERVICE); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service. public static ActivityComponent getActivityComponent(Context activityContext) { return (ActivityComponent) activityContext.getSystemService(INJECTOR_SERVICE); } @SuppressWarnings("ResourceType") // Explicitly doing a custom service.
public static UserComponent getUserComponent(Context activityContext) {
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.HttpUriRequest;
package net.scaliby.ceidgcaptcha.downloader.factory; public interface RequestFactory { HttpUriRequest createGenerateSessionRequest();
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.HttpUriRequest; package net.scaliby.ceidgcaptcha.downloader.factory; public interface RequestFactory { HttpUriRequest createGenerateSessionRequest();
HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource);
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule;
package net.scaliby.ceidgcaptcha.machinelearning; public class CEIDGCaptchaMachineLearningMain { public static void main(String[] args) { Injector injector = Guice.createInjector( new CEIDGCaptchaMachineLearningModule(),
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningMain.java import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; package net.scaliby.ceidgcaptcha.machinelearning; public class CEIDGCaptchaMachineLearningMain { public static void main(String[] args) { Injector injector = Guice.createInjector( new CEIDGCaptchaMachineLearningModule(),
new CEIDGCaptchaCommonModule(),
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule;
package net.scaliby.ceidgcaptcha.machinelearning; public class CEIDGCaptchaMachineLearningMain { public static void main(String[] args) { Injector injector = Guice.createInjector( new CEIDGCaptchaMachineLearningModule(), new CEIDGCaptchaCommonModule(),
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningMain.java import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; package net.scaliby.ceidgcaptcha.machinelearning; public class CEIDGCaptchaMachineLearningMain { public static void main(String[] args) { Injector injector = Guice.createInjector( new CEIDGCaptchaMachineLearningModule(), new CEIDGCaptchaCommonModule(),
new CEIDGCaptchaPropertiesModule()
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient;
private final CaptchaIdParser captchaIdParser;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser;
private final SessionIdParser sessionIdParser;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser;
private final RequestFactory requestFactory;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser; private final RequestFactory requestFactory;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser; private final RequestFactory requestFactory;
private final ImageParser imageParser;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser; private final RequestFactory requestFactory; private final ImageParser imageParser; @Inject public CEIDGClientImpl(CloseableHttpClient closeableHttpClient, CaptchaIdParser captchaIdParser, SessionIdParser sessionIdParser, ImageParser imageParser, RequestFactory requestFactory) { this.closeableHttpClient = closeableHttpClient; this.captchaIdParser = captchaIdParser; this.sessionIdParser = sessionIdParser; this.requestFactory = requestFactory; this.imageParser = imageParser; } @Override
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser; private final RequestFactory requestFactory; private final ImageParser imageParser; @Inject public CEIDGClientImpl(CloseableHttpClient closeableHttpClient, CaptchaIdParser captchaIdParser, SessionIdParser sessionIdParser, ImageParser imageParser, RequestFactory requestFactory) { this.closeableHttpClient = closeableHttpClient; this.captchaIdParser = captchaIdParser; this.sessionIdParser = sessionIdParser; this.requestFactory = requestFactory; this.imageParser = imageParser; } @Override
public CEIDGCaptchaSessionResource generateSession() {
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // }
import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser; private final RequestFactory requestFactory; private final ImageParser imageParser; @Inject public CEIDGClientImpl(CloseableHttpClient closeableHttpClient, CaptchaIdParser captchaIdParser, SessionIdParser sessionIdParser, ImageParser imageParser, RequestFactory requestFactory) { this.closeableHttpClient = closeableHttpClient; this.captchaIdParser = captchaIdParser; this.sessionIdParser = sessionIdParser; this.requestFactory = requestFactory; this.imageParser = imageParser; } @Override public CEIDGCaptchaSessionResource generateSession() { HttpUriRequest httpUriRequest = requestFactory.createGenerateSessionRequest(); try (CloseableHttpResponse response = closeableHttpClient.execute(httpUriRequest)) { return generateSessionInternal(response); } catch (IOException e) {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaIdParser.java // public interface CaptchaIdParser { // // Optional<String> parseCaptchaId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/SessionIdParser.java // public interface SessionIdParser { // // Optional<String> parseSessionId(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/CEIDGClientImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaIdParser; import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.common.SessionIdParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class CEIDGClientImpl implements CEIDGClient { private final CloseableHttpClient closeableHttpClient; private final CaptchaIdParser captchaIdParser; private final SessionIdParser sessionIdParser; private final RequestFactory requestFactory; private final ImageParser imageParser; @Inject public CEIDGClientImpl(CloseableHttpClient closeableHttpClient, CaptchaIdParser captchaIdParser, SessionIdParser sessionIdParser, ImageParser imageParser, RequestFactory requestFactory) { this.closeableHttpClient = closeableHttpClient; this.captchaIdParser = captchaIdParser; this.sessionIdParser = sessionIdParser; this.requestFactory = requestFactory; this.imageParser = imageParser; } @Override public CEIDGCaptchaSessionResource generateSession() { HttpUriRequest httpUriRequest = requestFactory.createGenerateSessionRequest(); try (CloseableHttpResponse response = closeableHttpClient.execute(httpUriRequest)) { return generateSessionInternal(response); } catch (IOException e) {
throw new CEIDGHttpException(e);
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/RequestFactoryImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CookieParser.java // public interface CookieParser { // Map<String, String> parseSetCookieStrings(Collection<String> input); // // String formatCookieString(Map<String, String> cookies); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGClientEndpointConfigurationResource.java // @Data // public class CEIDGClientEndpointConfigurationResource { // // @Inject // @Named("application.ceidg.client.endpoint.sessionGenerateUrl") // private String sessionGenerateUrl; // @Inject // @Named("application.ceidg.client.endpoint.imageDownloadUrl") // private String imageDownloadUrl; // // }
import net.scaliby.ceidgcaptcha.downloader.common.CookieParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGClientEndpointConfigurationResource; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import javax.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map;
package net.scaliby.ceidgcaptcha.downloader.factory.impl; public class RequestFactoryImpl implements RequestFactory { private final CEIDGClientEndpointConfigurationResource ceidgClientEndpointConfigurationResource;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CookieParser.java // public interface CookieParser { // Map<String, String> parseSetCookieStrings(Collection<String> input); // // String formatCookieString(Map<String, String> cookies); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGClientEndpointConfigurationResource.java // @Data // public class CEIDGClientEndpointConfigurationResource { // // @Inject // @Named("application.ceidg.client.endpoint.sessionGenerateUrl") // private String sessionGenerateUrl; // @Inject // @Named("application.ceidg.client.endpoint.imageDownloadUrl") // private String imageDownloadUrl; // // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/RequestFactoryImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CookieParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGClientEndpointConfigurationResource; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import javax.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; package net.scaliby.ceidgcaptcha.downloader.factory.impl; public class RequestFactoryImpl implements RequestFactory { private final CEIDGClientEndpointConfigurationResource ceidgClientEndpointConfigurationResource;
private final CookieParser cookieParser;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/RequestFactoryImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CookieParser.java // public interface CookieParser { // Map<String, String> parseSetCookieStrings(Collection<String> input); // // String formatCookieString(Map<String, String> cookies); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGClientEndpointConfigurationResource.java // @Data // public class CEIDGClientEndpointConfigurationResource { // // @Inject // @Named("application.ceidg.client.endpoint.sessionGenerateUrl") // private String sessionGenerateUrl; // @Inject // @Named("application.ceidg.client.endpoint.imageDownloadUrl") // private String imageDownloadUrl; // // }
import net.scaliby.ceidgcaptcha.downloader.common.CookieParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGClientEndpointConfigurationResource; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import javax.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map;
package net.scaliby.ceidgcaptcha.downloader.factory.impl; public class RequestFactoryImpl implements RequestFactory { private final CEIDGClientEndpointConfigurationResource ceidgClientEndpointConfigurationResource; private final CookieParser cookieParser; @Inject public RequestFactoryImpl(CEIDGClientEndpointConfigurationResource ceidgClientEndpointConfigurationResource, CookieParser cookieParser) { this.ceidgClientEndpointConfigurationResource = ceidgClientEndpointConfigurationResource; this.cookieParser = cookieParser; } @Override public HttpUriRequest createGenerateSessionRequest() { return new HttpGet(ceidgClientEndpointConfigurationResource.getSessionGenerateUrl()); } @Override
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CookieParser.java // public interface CookieParser { // Map<String, String> parseSetCookieStrings(Collection<String> input); // // String formatCookieString(Map<String, String> cookies); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGClientEndpointConfigurationResource.java // @Data // public class CEIDGClientEndpointConfigurationResource { // // @Inject // @Named("application.ceidg.client.endpoint.sessionGenerateUrl") // private String sessionGenerateUrl; // @Inject // @Named("application.ceidg.client.endpoint.imageDownloadUrl") // private String imageDownloadUrl; // // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/RequestFactoryImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CookieParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGClientEndpointConfigurationResource; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import javax.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; package net.scaliby.ceidgcaptcha.downloader.factory.impl; public class RequestFactoryImpl implements RequestFactory { private final CEIDGClientEndpointConfigurationResource ceidgClientEndpointConfigurationResource; private final CookieParser cookieParser; @Inject public RequestFactoryImpl(CEIDGClientEndpointConfigurationResource ceidgClientEndpointConfigurationResource, CookieParser cookieParser) { this.ceidgClientEndpointConfigurationResource = ceidgClientEndpointConfigurationResource; this.cookieParser = cookieParser; } @Override public HttpUriRequest createGenerateSessionRequest() { return new HttpGet(ceidgClientEndpointConfigurationResource.getSessionGenerateUrl()); } @Override
public HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) {
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/RequestFactoryImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CookieParser.java // public interface CookieParser { // Map<String, String> parseSetCookieStrings(Collection<String> input); // // String formatCookieString(Map<String, String> cookies); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGClientEndpointConfigurationResource.java // @Data // public class CEIDGClientEndpointConfigurationResource { // // @Inject // @Named("application.ceidg.client.endpoint.sessionGenerateUrl") // private String sessionGenerateUrl; // @Inject // @Named("application.ceidg.client.endpoint.imageDownloadUrl") // private String imageDownloadUrl; // // }
import net.scaliby.ceidgcaptcha.downloader.common.CookieParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGClientEndpointConfigurationResource; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import javax.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map;
this.cookieParser = cookieParser; } @Override public HttpUriRequest createGenerateSessionRequest() { return new HttpGet(ceidgClientEndpointConfigurationResource.getSessionGenerateUrl()); } @Override public HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) { URI uri = buildURI(ceidgCaptchaSessionResource); String cookieString = getCookieString(ceidgCaptchaSessionResource); HttpUriRequest httpUriRequest = new HttpGet(uri); httpUriRequest.setHeader("Cookie", cookieString); return httpUriRequest; } private String getCookieString(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) { Map<String, String> cookies = new HashMap<>(); cookies.put("ASP.NET_SessionId", ceidgCaptchaSessionResource.getSessionId()); return cookieParser.formatCookieString(cookies); } private URI buildURI(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) { try { URIBuilder uriBuilder = new URIBuilder(ceidgClientEndpointConfigurationResource.getImageDownloadUrl()) .addParameter("part", "0") .addParameter("id", ceidgCaptchaSessionResource.getCaptchaId()); return uriBuilder.build(); } catch (URISyntaxException e) {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CookieParser.java // public interface CookieParser { // Map<String, String> parseSetCookieStrings(Collection<String> input); // // String formatCookieString(Map<String, String> cookies); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/RequestFactory.java // public interface RequestFactory { // // HttpUriRequest createGenerateSessionRequest(); // // HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGClientEndpointConfigurationResource.java // @Data // public class CEIDGClientEndpointConfigurationResource { // // @Inject // @Named("application.ceidg.client.endpoint.sessionGenerateUrl") // private String sessionGenerateUrl; // @Inject // @Named("application.ceidg.client.endpoint.imageDownloadUrl") // private String imageDownloadUrl; // // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/RequestFactoryImpl.java import net.scaliby.ceidgcaptcha.downloader.common.CookieParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import net.scaliby.ceidgcaptcha.downloader.factory.RequestFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGClientEndpointConfigurationResource; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import javax.inject.Inject; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; this.cookieParser = cookieParser; } @Override public HttpUriRequest createGenerateSessionRequest() { return new HttpGet(ceidgClientEndpointConfigurationResource.getSessionGenerateUrl()); } @Override public HttpUriRequest createGetCaptchaImageRequest(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) { URI uri = buildURI(ceidgCaptchaSessionResource); String cookieString = getCookieString(ceidgCaptchaSessionResource); HttpUriRequest httpUriRequest = new HttpGet(uri); httpUriRequest.setHeader("Cookie", cookieString); return httpUriRequest; } private String getCookieString(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) { Map<String, String> cookies = new HashMap<>(); cookies.put("ASP.NET_SessionId", ceidgCaptchaSessionResource.getSessionId()); return cookieParser.formatCookieString(cookies); } private URI buildURI(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource) { try { URIBuilder uriBuilder = new URIBuilder(ceidgClientEndpointConfigurationResource.getImageDownloadUrl()) .addParameter("part", "0") .addParameter("id", ceidgCaptchaSessionResource.getCaptchaId()); return uriBuilder.build(); } catch (URISyntaxException e) {
throw new CEIDGHttpException(e);
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/ByteArrayToBufferedImageConverter.java // public interface ByteArrayToBufferedImageConverter { // // BufferedImage convert(byte[] data); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/resource/CEIDGCaptchaResponseResource.java // @Data // public class CEIDGCaptchaResponseResource { // // private String prediction; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // }
import net.scaliby.ceidgcaptcha.rest.converter.ByteArrayToBufferedImageConverter; import net.scaliby.ceidgcaptcha.rest.resource.CEIDGCaptchaResponseResource; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import ratpack.form.Form; import ratpack.form.UploadedFile; import ratpack.handling.Context; import ratpack.handling.Handler; import javax.inject.Inject; import java.awt.image.BufferedImage; import static ratpack.jackson.Jackson.json;
package net.scaliby.ceidgcaptcha.rest.handler; public class CEIDGCaptchaPredictionHandler implements Handler { private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService;
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/ByteArrayToBufferedImageConverter.java // public interface ByteArrayToBufferedImageConverter { // // BufferedImage convert(byte[] data); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/resource/CEIDGCaptchaResponseResource.java // @Data // public class CEIDGCaptchaResponseResource { // // private String prediction; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java import net.scaliby.ceidgcaptcha.rest.converter.ByteArrayToBufferedImageConverter; import net.scaliby.ceidgcaptcha.rest.resource.CEIDGCaptchaResponseResource; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import ratpack.form.Form; import ratpack.form.UploadedFile; import ratpack.handling.Context; import ratpack.handling.Handler; import javax.inject.Inject; import java.awt.image.BufferedImage; import static ratpack.jackson.Jackson.json; package net.scaliby.ceidgcaptcha.rest.handler; public class CEIDGCaptchaPredictionHandler implements Handler { private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService;
private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter;
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/ByteArrayToBufferedImageConverter.java // public interface ByteArrayToBufferedImageConverter { // // BufferedImage convert(byte[] data); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/resource/CEIDGCaptchaResponseResource.java // @Data // public class CEIDGCaptchaResponseResource { // // private String prediction; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // }
import net.scaliby.ceidgcaptcha.rest.converter.ByteArrayToBufferedImageConverter; import net.scaliby.ceidgcaptcha.rest.resource.CEIDGCaptchaResponseResource; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import ratpack.form.Form; import ratpack.form.UploadedFile; import ratpack.handling.Context; import ratpack.handling.Handler; import javax.inject.Inject; import java.awt.image.BufferedImage; import static ratpack.jackson.Jackson.json;
package net.scaliby.ceidgcaptcha.rest.handler; public class CEIDGCaptchaPredictionHandler implements Handler { private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; @Inject public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; } @Override public void handle(Context ctx) throws Exception { ctx.parse(Form.class).then(form -> { UploadedFile image = form.file("image"); BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); String prediction = ceidgCaptchaPredictionService.predict(bufferedImage);
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/ByteArrayToBufferedImageConverter.java // public interface ByteArrayToBufferedImageConverter { // // BufferedImage convert(byte[] data); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/resource/CEIDGCaptchaResponseResource.java // @Data // public class CEIDGCaptchaResponseResource { // // private String prediction; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java import net.scaliby.ceidgcaptcha.rest.converter.ByteArrayToBufferedImageConverter; import net.scaliby.ceidgcaptcha.rest.resource.CEIDGCaptchaResponseResource; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import ratpack.form.Form; import ratpack.form.UploadedFile; import ratpack.handling.Context; import ratpack.handling.Handler; import javax.inject.Inject; import java.awt.image.BufferedImage; import static ratpack.jackson.Jackson.json; package net.scaliby.ceidgcaptcha.rest.handler; public class CEIDGCaptchaPredictionHandler implements Handler { private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; @Inject public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; } @Override public void handle(Context ctx) throws Exception { ctx.parse(Form.class).then(form -> { UploadedFile image = form.file("image"); BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); String prediction = ceidgCaptchaPredictionService.predict(bufferedImage);
CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource();
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/CEIDGCaptchaDownloaderRunner.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.Setter; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.downloader; public class CEIDGCaptchaDownloaderRunner implements Runnable { private static final String IMAGES_FORMAT = "png"; private static final int IMAGES_COUNT = 1000;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/CEIDGCaptchaDownloaderRunner.java import lombok.Setter; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.downloader; public class CEIDGCaptchaDownloaderRunner implements Runnable { private static final String IMAGES_FORMAT = "png"; private static final int IMAGES_COUNT = 1000;
private final CaptchaDownloaderService captchaDownloaderService;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/InputSplitServiceImpl.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // }
import lombok.Setter; import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import org.datavec.api.io.filters.BalancedPathFilter; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.FileSplit; import org.datavec.api.split.InputSplit; import org.datavec.image.loader.NativeImageLoader; import javax.inject.Inject; import java.io.File; import java.util.Random;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; @Log4j public class InputSplitServiceImpl implements InputSplitService { private static final float TRAIN_WEIGHT = 0.75f; private static final float TEST_WEIGHT = 0.25f; private final PathLabelGenerator pathLabelGenerator; private final Random random;
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/InputSplitServiceImpl.java import lombok.Setter; import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import org.datavec.api.io.filters.BalancedPathFilter; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.FileSplit; import org.datavec.api.split.InputSplit; import org.datavec.image.loader.NativeImageLoader; import javax.inject.Inject; import java.io.File; import java.util.Random; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; @Log4j public class InputSplitServiceImpl implements InputSplitService { private static final float TRAIN_WEIGHT = 0.75f; private static final float TEST_WEIGHT = 0.25f; private final PathLabelGenerator pathLabelGenerator; private final Random random;
private final StoreChooser storeChooser;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/InputSplitServiceImpl.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // }
import lombok.Setter; import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import org.datavec.api.io.filters.BalancedPathFilter; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.FileSplit; import org.datavec.api.split.InputSplit; import org.datavec.image.loader.NativeImageLoader; import javax.inject.Inject; import java.io.File; import java.util.Random;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; @Log4j public class InputSplitServiceImpl implements InputSplitService { private static final float TRAIN_WEIGHT = 0.75f; private static final float TEST_WEIGHT = 0.25f; private final PathLabelGenerator pathLabelGenerator; private final Random random; private final StoreChooser storeChooser; @Setter private float trainWeight = TRAIN_WEIGHT; @Setter private float testWeight = TEST_WEIGHT; @Inject public InputSplitServiceImpl(PathLabelGenerator pathLabelGenerator, Random random, StoreChooser storeChooser) { this.pathLabelGenerator = pathLabelGenerator; this.random = random; this.storeChooser = storeChooser; } @Override
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/InputSplitServiceImpl.java import lombok.Setter; import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import org.datavec.api.io.filters.BalancedPathFilter; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.FileSplit; import org.datavec.api.split.InputSplit; import org.datavec.image.loader.NativeImageLoader; import javax.inject.Inject; import java.io.File; import java.util.Random; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; @Log4j public class InputSplitServiceImpl implements InputSplitService { private static final float TRAIN_WEIGHT = 0.75f; private static final float TEST_WEIGHT = 0.25f; private final PathLabelGenerator pathLabelGenerator; private final Random random; private final StoreChooser storeChooser; @Setter private float trainWeight = TRAIN_WEIGHT; @Setter private float testWeight = TEST_WEIGHT; @Inject public InputSplitServiceImpl(PathLabelGenerator pathLabelGenerator, Random random, StoreChooser storeChooser) { this.pathLabelGenerator = pathLabelGenerator; this.random = random; this.storeChooser = storeChooser; } @Override
public InputSplitResource getInputSplit() {
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/InputSplitServiceImpl.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // }
import lombok.Setter; import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import org.datavec.api.io.filters.BalancedPathFilter; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.FileSplit; import org.datavec.api.split.InputSplit; import org.datavec.image.loader.NativeImageLoader; import javax.inject.Inject; import java.io.File; import java.util.Random;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; @Log4j public class InputSplitServiceImpl implements InputSplitService { private static final float TRAIN_WEIGHT = 0.75f; private static final float TEST_WEIGHT = 0.25f; private final PathLabelGenerator pathLabelGenerator; private final Random random; private final StoreChooser storeChooser; @Setter private float trainWeight = TRAIN_WEIGHT; @Setter private float testWeight = TEST_WEIGHT; @Inject public InputSplitServiceImpl(PathLabelGenerator pathLabelGenerator, Random random, StoreChooser storeChooser) { this.pathLabelGenerator = pathLabelGenerator; this.random = random; this.storeChooser = storeChooser; } @Override public InputSplitResource getInputSplit() { log.info("Select images location"); File file = storeChooser.getDirectory()
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/InputSplitServiceImpl.java import lombok.Setter; import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import org.datavec.api.io.filters.BalancedPathFilter; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.FileSplit; import org.datavec.api.split.InputSplit; import org.datavec.image.loader.NativeImageLoader; import javax.inject.Inject; import java.io.File; import java.util.Random; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; @Log4j public class InputSplitServiceImpl implements InputSplitService { private static final float TRAIN_WEIGHT = 0.75f; private static final float TEST_WEIGHT = 0.25f; private final PathLabelGenerator pathLabelGenerator; private final Random random; private final StoreChooser storeChooser; @Setter private float trainWeight = TRAIN_WEIGHT; @Setter private float testWeight = TEST_WEIGHT; @Inject public InputSplitServiceImpl(PathLabelGenerator pathLabelGenerator, Random random, StoreChooser storeChooser) { this.pathLabelGenerator = pathLabelGenerator; this.random = random; this.storeChooser = storeChooser; } @Override public InputSplitResource getInputSplit() { log.info("Select images location"); File file = storeChooser.getDirectory()
.orElseThrow(() -> new ImageStoreException("No store chosen"));
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/impl/ByteArrayToBufferedImageConverterImpl.java
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/exception/ImageProcessingException.java // public class ImageProcessingException extends RuntimeException { // public ImageProcessingException() { // } // // public ImageProcessingException(String message) { // super(message); // } // // public ImageProcessingException(String message, Throwable cause) { // super(message, cause); // } // // public ImageProcessingException(Throwable cause) { // super(cause); // } // // public ImageProcessingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/ByteArrayToBufferedImageConverter.java // public interface ByteArrayToBufferedImageConverter { // // BufferedImage convert(byte[] data); // // }
import net.scaliby.ceidgcaptcha.rest.exception.ImageProcessingException; import net.scaliby.ceidgcaptcha.rest.converter.ByteArrayToBufferedImageConverter; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException;
package net.scaliby.ceidgcaptcha.rest.converter.impl; public class ByteArrayToBufferedImageConverterImpl implements ByteArrayToBufferedImageConverter { @Override public BufferedImage convert(byte[] data) { try { return ImageIO.read(new ByteArrayInputStream(data)); } catch (IOException e) {
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/exception/ImageProcessingException.java // public class ImageProcessingException extends RuntimeException { // public ImageProcessingException() { // } // // public ImageProcessingException(String message) { // super(message); // } // // public ImageProcessingException(String message, Throwable cause) { // super(message, cause); // } // // public ImageProcessingException(Throwable cause) { // super(cause); // } // // public ImageProcessingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/ByteArrayToBufferedImageConverter.java // public interface ByteArrayToBufferedImageConverter { // // BufferedImage convert(byte[] data); // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/impl/ByteArrayToBufferedImageConverterImpl.java import net.scaliby.ceidgcaptcha.rest.exception.ImageProcessingException; import net.scaliby.ceidgcaptcha.rest.converter.ByteArrayToBufferedImageConverter; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; package net.scaliby.ceidgcaptcha.rest.converter.impl; public class ByteArrayToBufferedImageConverterImpl implements ByteArrayToBufferedImageConverter { @Override public BufferedImage convert(byte[] data) { try { return ImageIO.read(new ByteArrayInputStream(data)); } catch (IOException e) {
throw new ImageProcessingException(e);
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/MultiLayerConfigurationFactoryImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // }
import lombok.Setter; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.conf.NeuralNetConfiguration; import org.deeplearning4j.nn.conf.Updater; import org.deeplearning4j.nn.conf.inputs.InputType; import org.deeplearning4j.nn.conf.layers.DenseLayer; import org.deeplearning4j.nn.conf.layers.OutputLayer; import org.deeplearning4j.nn.weights.WeightInit; import org.nd4j.linalg.activations.Activation; import org.nd4j.linalg.lossfunctions.LossFunctions; import javax.inject.Inject; import javax.inject.Named;
package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class MultiLayerConfigurationFactoryImpl implements MultiLayerConfigurationFactory { private static final int SEED = 1337; @Setter @Inject @Named("application.seed") private int seed = SEED;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/MultiLayerConfigurationFactoryImpl.java import lombok.Setter; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.conf.NeuralNetConfiguration; import org.deeplearning4j.nn.conf.Updater; import org.deeplearning4j.nn.conf.inputs.InputType; import org.deeplearning4j.nn.conf.layers.DenseLayer; import org.deeplearning4j.nn.conf.layers.OutputLayer; import org.deeplearning4j.nn.weights.WeightInit; import org.nd4j.linalg.activations.Activation; import org.nd4j.linalg.lossfunctions.LossFunctions; import javax.inject.Inject; import javax.inject.Named; package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class MultiLayerConfigurationFactoryImpl implements MultiLayerConfigurationFactory { private static final int SEED = 1337; @Setter @Inject @Named("application.seed") private int seed = SEED;
private final ImageTransformConfigurationResource imageTransformConfigurationResource;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/MultiLayerConfigurationFactoryImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // }
import lombok.Setter; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.conf.NeuralNetConfiguration; import org.deeplearning4j.nn.conf.Updater; import org.deeplearning4j.nn.conf.inputs.InputType; import org.deeplearning4j.nn.conf.layers.DenseLayer; import org.deeplearning4j.nn.conf.layers.OutputLayer; import org.deeplearning4j.nn.weights.WeightInit; import org.nd4j.linalg.activations.Activation; import org.nd4j.linalg.lossfunctions.LossFunctions; import javax.inject.Inject; import javax.inject.Named;
package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class MultiLayerConfigurationFactoryImpl implements MultiLayerConfigurationFactory { private static final int SEED = 1337; @Setter @Inject @Named("application.seed") private int seed = SEED; private final ImageTransformConfigurationResource imageTransformConfigurationResource;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/MultiLayerConfigurationFactoryImpl.java import lombok.Setter; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.conf.NeuralNetConfiguration; import org.deeplearning4j.nn.conf.Updater; import org.deeplearning4j.nn.conf.inputs.InputType; import org.deeplearning4j.nn.conf.layers.DenseLayer; import org.deeplearning4j.nn.conf.layers.OutputLayer; import org.deeplearning4j.nn.weights.WeightInit; import org.nd4j.linalg.activations.Activation; import org.nd4j.linalg.lossfunctions.LossFunctions; import javax.inject.Inject; import javax.inject.Named; package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class MultiLayerConfigurationFactoryImpl implements MultiLayerConfigurationFactory { private static final int SEED = 1337; @Setter @Inject @Named("application.seed") private int seed = SEED; private final ImageTransformConfigurationResource imageTransformConfigurationResource;
private final NetworkConfigurationResource networkConfigurationResource;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // }
import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
package net.scaliby.ceidgcaptcha.machinelearning.service; public interface MachineLearningService { void train(MultiLayerNetwork multiLayerNetwork);
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; package net.scaliby.ceidgcaptcha.machinelearning.service; public interface MachineLearningService { void train(MultiLayerNetwork multiLayerNetwork);
NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork);
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/impl/BufferedImageToINDArrayConverterImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/exception/ImageProcessingException.java // public class ImageProcessingException extends RuntimeException { // public ImageProcessingException() { // } // // public ImageProcessingException(String message) { // super(message); // } // // public ImageProcessingException(String message, Throwable cause) { // super(message, cause); // } // // public ImageProcessingException(Throwable cause) { // super(cause); // } // // public ImageProcessingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.exception.ImageProcessingException; import org.datavec.image.loader.NativeImageLoader; import org.datavec.image.transform.ImageTransform; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.rest.converter.impl; public class BufferedImageToINDArrayConverterImpl implements BufferedImageToINDArrayConverter { private final ImageTransformFactory imageTransformFactory;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/exception/ImageProcessingException.java // public class ImageProcessingException extends RuntimeException { // public ImageProcessingException() { // } // // public ImageProcessingException(String message) { // super(message); // } // // public ImageProcessingException(String message, Throwable cause) { // super(message, cause); // } // // public ImageProcessingException(Throwable cause) { // super(cause); // } // // public ImageProcessingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/impl/BufferedImageToINDArrayConverterImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.exception.ImageProcessingException; import org.datavec.image.loader.NativeImageLoader; import org.datavec.image.transform.ImageTransform; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.rest.converter.impl; public class BufferedImageToINDArrayConverterImpl implements BufferedImageToINDArrayConverter { private final ImageTransformFactory imageTransformFactory;
private final ImageTransformConfigurationResource imageTransformConfigurationResource;
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/impl/BufferedImageToINDArrayConverterImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/exception/ImageProcessingException.java // public class ImageProcessingException extends RuntimeException { // public ImageProcessingException() { // } // // public ImageProcessingException(String message) { // super(message); // } // // public ImageProcessingException(String message, Throwable cause) { // super(message, cause); // } // // public ImageProcessingException(Throwable cause) { // super(cause); // } // // public ImageProcessingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.exception.ImageProcessingException; import org.datavec.image.loader.NativeImageLoader; import org.datavec.image.transform.ImageTransform; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.rest.converter.impl; public class BufferedImageToINDArrayConverterImpl implements BufferedImageToINDArrayConverter { private final ImageTransformFactory imageTransformFactory; private final ImageTransformConfigurationResource imageTransformConfigurationResource; @Inject public BufferedImageToINDArrayConverterImpl(ImageTransformFactory imageTransformFactory, ImageTransformConfigurationResource imageTransformConfigurationResource) { this.imageTransformFactory = imageTransformFactory; this.imageTransformConfigurationResource = imageTransformConfigurationResource; } @Override public INDArray convert(BufferedImage bufferedImage) { try { ImageTransform transform = imageTransformFactory.create(); int height = imageTransformConfigurationResource.getScaledHeight(); int width = imageTransformConfigurationResource.getScaledWidth(); int channels = imageTransformConfigurationResource.getChannels(); return new NativeImageLoader(height, width, channels, transform).asMatrix(bufferedImage); } catch (IOException ex) {
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/exception/ImageProcessingException.java // public class ImageProcessingException extends RuntimeException { // public ImageProcessingException() { // } // // public ImageProcessingException(String message) { // super(message); // } // // public ImageProcessingException(String message, Throwable cause) { // super(message, cause); // } // // public ImageProcessingException(Throwable cause) { // super(cause); // } // // public ImageProcessingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/impl/BufferedImageToINDArrayConverterImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.exception.ImageProcessingException; import org.datavec.image.loader.NativeImageLoader; import org.datavec.image.transform.ImageTransform; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.rest.converter.impl; public class BufferedImageToINDArrayConverterImpl implements BufferedImageToINDArrayConverter { private final ImageTransformFactory imageTransformFactory; private final ImageTransformConfigurationResource imageTransformConfigurationResource; @Inject public BufferedImageToINDArrayConverterImpl(ImageTransformFactory imageTransformFactory, ImageTransformConfigurationResource imageTransformConfigurationResource) { this.imageTransformFactory = imageTransformFactory; this.imageTransformConfigurationResource = imageTransformConfigurationResource; } @Override public INDArray convert(BufferedImage bufferedImage) { try { ImageTransform transform = imageTransformFactory.create(); int height = imageTransformConfigurationResource.getScaledHeight(); int width = imageTransformConfigurationResource.getScaledWidth(); int channels = imageTransformConfigurationResource.getChannels(); return new NativeImageLoader(height, width, channels, transform).asMatrix(bufferedImage); } catch (IOException ex) {
throw new ImageProcessingException(ex);
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService {
private final CaptchaLabeler captchaLabeler;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler;
private final StoreChooser storeChooser;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser;
private final CEIDGClient ceidgClient;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient;
private final ImageStoreFactory imageStoreFactory;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory;
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory;
private final ImageWriter imageWriter;
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory; private final ImageWriter imageWriter; @Inject public CaptchaDownloaderServiceImpl(CaptchaLabeler captchaLabeler, StoreChooser storeChooser, CEIDGClient ceidgClient, ImageStoreFactory imageStoreFactory, ImageWriter imageWriter) { this.captchaLabeler = captchaLabeler; this.storeChooser = storeChooser; this.ceidgClient = ceidgClient; this.imageStoreFactory = imageStoreFactory; this.imageWriter = imageWriter; } @Override public void downloadCaptchaImages(int imagesCount, String format) {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory; private final ImageWriter imageWriter; @Inject public CaptchaDownloaderServiceImpl(CaptchaLabeler captchaLabeler, StoreChooser storeChooser, CEIDGClient ceidgClient, ImageStoreFactory imageStoreFactory, ImageWriter imageWriter) { this.captchaLabeler = captchaLabeler; this.storeChooser = storeChooser; this.ceidgClient = ceidgClient; this.imageStoreFactory = imageStoreFactory; this.imageWriter = imageWriter; } @Override public void downloadCaptchaImages(int imagesCount, String format) {
CEIDGCaptchaSessionResource session = ceidgClient.generateSession();
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory; private final ImageWriter imageWriter; @Inject public CaptchaDownloaderServiceImpl(CaptchaLabeler captchaLabeler, StoreChooser storeChooser, CEIDGClient ceidgClient, ImageStoreFactory imageStoreFactory, ImageWriter imageWriter) { this.captchaLabeler = captchaLabeler; this.storeChooser = storeChooser; this.ceidgClient = ceidgClient; this.imageStoreFactory = imageStoreFactory; this.imageWriter = imageWriter; } @Override public void downloadCaptchaImages(int imagesCount, String format) { CEIDGCaptchaSessionResource session = ceidgClient.generateSession(); File imageStore = getStore(session); downloadImages(imagesCount, format, imageStore, session); } private File getStore(CEIDGCaptchaSessionResource session) { File storeBasePath = storeChooser.getDirectory()
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory; private final ImageWriter imageWriter; @Inject public CaptchaDownloaderServiceImpl(CaptchaLabeler captchaLabeler, StoreChooser storeChooser, CEIDGClient ceidgClient, ImageStoreFactory imageStoreFactory, ImageWriter imageWriter) { this.captchaLabeler = captchaLabeler; this.storeChooser = storeChooser; this.ceidgClient = ceidgClient; this.imageStoreFactory = imageStoreFactory; this.imageWriter = imageWriter; } @Override public void downloadCaptchaImages(int imagesCount, String format) { CEIDGCaptchaSessionResource session = ceidgClient.generateSession(); File imageStore = getStore(session); downloadImages(imagesCount, format, imageStore, session); } private File getStore(CEIDGCaptchaSessionResource session) { File storeBasePath = storeChooser.getDirectory()
.orElseThrow(() -> new ImageStoreException("No store selected"));
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory; private final ImageWriter imageWriter; @Inject public CaptchaDownloaderServiceImpl(CaptchaLabeler captchaLabeler, StoreChooser storeChooser, CEIDGClient ceidgClient, ImageStoreFactory imageStoreFactory, ImageWriter imageWriter) { this.captchaLabeler = captchaLabeler; this.storeChooser = storeChooser; this.ceidgClient = ceidgClient; this.imageStoreFactory = imageStoreFactory; this.imageWriter = imageWriter; } @Override public void downloadCaptchaImages(int imagesCount, String format) { CEIDGCaptchaSessionResource session = ceidgClient.generateSession(); File imageStore = getStore(session); downloadImages(imagesCount, format, imageStore, session); } private File getStore(CEIDGCaptchaSessionResource session) { File storeBasePath = storeChooser.getDirectory() .orElseThrow(() -> new ImageStoreException("No store selected")); BufferedImage imageToLabel = ceidgClient.getCaptchaImage(session); String label = captchaLabeler.getLabel(imageToLabel)
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CEIDGClient.java // public interface CEIDGClient { // CEIDGCaptchaSessionResource generateSession(); // // BufferedImage getCaptchaImage(CEIDGCaptchaSessionResource ceidgCaptchaSessionResource); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/resource/CEIDGCaptchaSessionResource.java // @Data // public class CEIDGCaptchaSessionResource { // private String sessionId; // private String captchaId; // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/CaptchaDownloaderService.java // public interface CaptchaDownloaderService { // void downloadCaptchaImages(int imagesCount, String format); // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/service/impl/CaptchaDownloaderServiceImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.downloader.common.CEIDGClient; import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import net.scaliby.ceidgcaptcha.downloader.resource.CEIDGCaptchaSessionResource; import net.scaliby.ceidgcaptcha.downloader.service.CaptchaDownloaderService; import javax.inject.Inject; import java.awt.image.BufferedImage; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.service.impl; @Log4j public class CaptchaDownloaderServiceImpl implements CaptchaDownloaderService { private final CaptchaLabeler captchaLabeler; private final StoreChooser storeChooser; private final CEIDGClient ceidgClient; private final ImageStoreFactory imageStoreFactory; private final ImageWriter imageWriter; @Inject public CaptchaDownloaderServiceImpl(CaptchaLabeler captchaLabeler, StoreChooser storeChooser, CEIDGClient ceidgClient, ImageStoreFactory imageStoreFactory, ImageWriter imageWriter) { this.captchaLabeler = captchaLabeler; this.storeChooser = storeChooser; this.ceidgClient = ceidgClient; this.imageStoreFactory = imageStoreFactory; this.imageWriter = imageWriter; } @Override public void downloadCaptchaImages(int imagesCount, String format) { CEIDGCaptchaSessionResource session = ceidgClient.generateSession(); File imageStore = getStore(session); downloadImages(imagesCount, format, imageStore, session); } private File getStore(CEIDGCaptchaSessionResource session) { File storeBasePath = storeChooser.getDirectory() .orElseThrow(() -> new ImageStoreException("No store selected")); BufferedImage imageToLabel = ceidgClient.getCaptchaImage(session); String label = captchaLabeler.getLabel(imageToLabel)
.orElseThrow(() -> new CaptchaLabelingException("No label provided"));
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/CEIDGCaptchaDownloaderMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader; public class CEIDGCaptchaDownloaderMain { public static void main(String[] args) throws IOException { Injector injector = Guice.createInjector(
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/CEIDGCaptchaDownloaderMain.java import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader; public class CEIDGCaptchaDownloaderMain { public static void main(String[] args) throws IOException { Injector injector = Guice.createInjector(
new CEIDGCaptchaPropertiesModule(),
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/CEIDGCaptchaDownloaderMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader; public class CEIDGCaptchaDownloaderMain { public static void main(String[] args) throws IOException { Injector injector = Guice.createInjector( new CEIDGCaptchaPropertiesModule(),
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/CEIDGCaptchaDownloaderMain.java import com.google.inject.Guice; import com.google.inject.Injector; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader; public class CEIDGCaptchaDownloaderMain { public static void main(String[] args) throws IOException { Injector injector = Guice.createInjector( new CEIDGCaptchaPropertiesModule(),
new CEIDGCaptchaCommonModule(),