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
def dagger_version = "2.16" | |
//dagger | |
implementation "com.google.dagger:dagger:$dagger_version" | |
kapt "com.google.dagger:dagger-compiler:$dagger_version" | |
implementation "com.google.dagger:dagger-android:$dagger_version" | |
implementation "com.google.dagger:dagger-android-support:$dagger_version" | |
// if you use the support libraries | |
kapt "com.google.dagger:dagger-android-processor:$dagger_version" |
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
interface NamesApi { | |
@GET("names") | |
fun getNamesAfter(@Query("after") afterName : String, @Query("limit") limit: Int) : Call<Array<String>> | |
} |
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
interface ProductsApi { | |
@GET("products") | |
fun searchProducts(@Query("searchTerm") searchTerm: String, @Query("page") page: Int) : Call<ProductsResponse> | |
@GET | |
fun getPageOfResults(@Url nextPageUrl: String) : Call<ProductsResponse> | |
} |
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
@Singleton | |
class TeamDiffCallback @Inject constructor() : DiffUtil.ItemCallback<Team>() { | |
override fun areItemsTheSame(oldItem: Team, newItem: Team): Boolean { | |
return oldItem.teamId == newItem.teamId && oldItem.competitionId == newItem.competitionId | |
} | |
override fun areContentsTheSame(oldItem: Team, newItem: Team): Boolean { | |
return oldItem.name == newItem.name && oldItem.crestUrl == newItem.crestUrl && oldItem.shortName == newItem.shortName | |
} |
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
class TeamsViewModel @Inject | |
constructor(private val teamDao: TeamDao) : ViewModel(){ | |
val liveTeamData: LiveData<PagedList<Team>> | |
init { | |
val teamsByNameDataSourceFactory = teamDao.loadTeamsByName() | |
val pagedListConfig = PagedList.Config.Builder() |
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
@Dao | |
interface TeamDao { | |
@Insert(onConflict = OnConflictStrategy.REPLACE) | |
fun insertTeam(team: Team) | |
@Query("SELECT * FROM teams order by name ASC") | |
fun loadTeamsByName() : DataSource.Factory<Integer, Team> | |
} |
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
docker build \ | |
--build-arg CLOUD_SSL_STORE_PASSWORD_ARG=changeit \ | |
--build-arg CLOUD_SSL_KEY_PASSWORD_ARG=changeit \ | |
--build-arg PAYARA_ADMIN_PASSWORD_ARG=changeit \ | |
--build-arg CLOUD_SQL_PASSWORD_ARG=reallychangeit \ | |
--build-arg CLOUD_SQL_JDBC_URL_ARG=<your-cloud-sql-jdbc-url> \ | |
--build-arg CLOUD_SQL_SERVER_NAME_ARG=<cloud-sql-server-name> \ | |
--build-arg CLOUD_SQL_USERNAME_ARG=<cloud-sql-app-user> \ | |
-t cloud-sql-payara . |
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
#Test that our connection to cloud sql is good | |
ping-connection-pool --user admin --passwordfile /tmp/password.txt jdbc/cloudsql-pool | |
#deploy the app | |
deploy /opt/application.war |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd"> | |
<resources> | |
<jdbc-connection-pool name="jdbc/cloudsql-pool" | |
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" | |
idle-timeout-in-seconds="150" | |
is-connection-validation-required="true" | |
connection-validation-method="auto-commit" | |
res-type="javax.sql.DataSource" > |
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
FROM openjdk:8-jdk | |
LABEL author="Brett Tucker" | |
LABEL version="1.0" | |
LABEL description="This image will use the pre boot and post boot payara scripts to add a \ | |
google cloud sql datasource to a payara server and then automatically deploy a given war file." | |
NewerOlder