This file contains hidden or 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
import io.swagger.annotations.ApiOperation; | |
import javax.ejb.Stateless; | |
import javax.inject.Inject; | |
import javax.servlet.ServletContext; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.core.Response; | |
import java.io.InputStream; |
This file contains hidden or 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
StoredProcedureQuery procedureQuery = entityManager.createStoredProcedureQuery(procedureName); | |
if (parameter.type == Clob.class) { | |
Connection connection = entityManager.unwrap(Connection.class); | |
try { | |
Clob clob = connection.createClob(); | |
clob.setString(1, (String) parameter.value); | |
procedureQuery.setParameter(parameter.name, clob); | |
} catch (SQLException e) { | |
throw new DatabaseClobException("io parameter " + parameter.name + ": " + parameter.value, e); |
This file contains hidden or 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 zencode.hazelcast; | |
import com.hazelcast.core.IMap; | |
import javax.inject.Inject; | |
/** | |
* Factory for clustered replicated data. | |
* @author Koert Zeilstra | |
*/ |
This file contains hidden or 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 zencode.hazelcast; | |
import com.hazelcast.core.Hazelcast; | |
import com.hazelcast.core.HazelcastInstance; | |
import javax.annotation.PostConstruct; | |
import javax.inject.Singleton; | |
/** | |
* Factory for Hazelcast instance. |
This file contains hidden or 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
/** | |
* Service to authenticate user with functional style. | |
* @author Koert Zeilstra | |
*/ | |
@Path("/authentication") | |
@ManagedBean | |
public class LoginService { | |
@Inject | |
private AuthenticationRepository authenticationRepository; |
This file contains hidden or 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
/** | |
* Service to authenticate user with classical if-null checking. | |
* @author Koert Zeilstra | |
*/ | |
@Path("/authentication") | |
@ManagedBean | |
public class LoginService2 { | |
@Inject | |
private AuthenticationRepository authenticationRepository; |
This file contains hidden or 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
/** | |
* Repository for authentication. | |
* @author Koert Zeilstra | |
*/ | |
@ApplicationScoped | |
public class AuthenticationRepository { | |
private Map<String, AuthenticationToken> tokenCache = new HashMap<>(); | |
public Optional<AuthenticationToken> authenticateUser(String userName, String password) { |
This file contains hidden or 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 enterprise.programmatic_login; | |
import java.io.*; | |
import java.net.*; | |
import javax.annotation.security.DeclareRoles; | |
import javax.servlet.*; | |
import javax.servlet.http.*; | |
/** | |
* Copied from https://docs.oracle.com/javaee/6/tutorial/doc/gjiie.html |
This file contains hidden or 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 test; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.math.BigDecimal; | |
import javax.ejb.EJB; | |
import javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; |
This file contains hidden or 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
import javax.ws.rs.ApplicationPath; | |
import javax.ws.rs.core.Application; | |
/** | |
* Application configuration. | |
* See https://stackoverflow.com/questions/23508159/jax-rs-glassfish-eclipse-a-simple-web-service-doesnt-work | |
* @author Koert Zeilstra | |
*/ | |
@ApplicationPath("/") | |
public class TestServiceApplication extends Application { | |
} |
NewerOlder