This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jerseyandguice; | |
import javax.servlet.http.HttpServlet; | |
import javax.ws.rs.Path; | |
import com.google.inject.Inject; | |
import com.google.inject.Singleton; | |
@Path("/jg") | |
@Singleton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jerseyandguice; | |
public class DefaultDependancy implements Dependancy { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jerseyandguice; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.servlet.RequestScoped; | |
public class DependancyModule extends AbstractModule { | |
@Override | |
protected void configure() { | |
bind(Dependancy.class).to(DefaultDependancy.class).in(RequestScoped.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jerseyandguice; | |
import com.google.inject.Guice; | |
import com.google.inject.Injector; | |
import com.google.inject.servlet.GuiceServletContextListener; | |
import com.google.inject.servlet.ServletModule; | |
public class JGServletContextListener extends GuiceServletContextListener { | |
private final ServletModule customServletModule = new ServletModule() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Error in custom provider, com.google.inject.OutOfScopeException: Cannot access scoped object. Either we are not currently inside an HTTP Servlet request, or you may have forgotten to apply com.google.inject.servlet.GuiceFilter as a servlet filter for this request. | |
while locating jerseyandguice.Dependancy | |
1 error | |
at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:767) | |
at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793) | |
at jerseyandguice.GuiceWiringTest.shouldFailToGetDependancyBecauseOfScope(GuiceWiringTest.java:62) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jerseyandguice; | |
import static jerseyandguice.GuicedServletAssertion.assertInstantiablity; | |
import static jerseyandguice.GuicedServletAssertion.assertProvisioningType; | |
import static jerseyandguice.GuicedServletAssertion.expose; | |
import static org.testng.Assert.assertNotNull; | |
import org.testng.annotations.BeforeClass; | |
import org.testng.annotations.Test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jerseyandguice; | |
import static org.testng.Assert.assertNotNull; | |
import static org.testng.Assert.assertTrue; | |
import java.util.concurrent.atomic.AtomicReference; | |
import javax.servlet.FilterChain; | |
import javax.servlet.ServletRequest; | |
import javax.servlet.ServletResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean willBeAliveInTheNextGeneration() { | |
return shouldLiveOnToNextGeneration() || shouldBeCreatedByReproduction(); | |
} | |
private boolean shouldLiveOnToNextGeneration() { | |
return cell.isAlive() && ( cellHasTwoNeighbors() || cellHasThreeNeighbors()); | |
} | |
private boolean shouldBeCreatedByReproduction() { | |
return cell.isDead() && cellHasThreeNeighbors(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected Map<Cell, State> captureStateTransitions(Ecosystem ecosystem) { | |
Map<Cell, State> stateTransitions = createSelfMinimizingMap(); | |
for (Cell cell : ecosystem.getCells()) { | |
stateTransitions.put(cell, getRules().evaluate(ecosystem, cell)); | |
} | |
return stateTransitions; | |
} | |
package gol.impl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I saw him standin' there by the CI machine | |
I knew he must a been about seventeen | |
The beat was goin' strong | |
Buildin' my favorite Long | |
An' I could tell it wouldn't be long | |
Till the light would be green, yeah green | |
And I could tell it wouldn't be long | |
Till the light would be green, yeah green, singin' | |
I love awesome code |
OlderNewer