From 59ead1c79c4689927dedf2e73cc6699786fb5a3b Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Wed, 15 Apr 2020 21:59:52 +0200 Subject: [PATCH] Removed signing, Changed Glassfish Version, Added LibraryVersion, Fixed SpecificBinder of the webhook --- pom.xml | 14 --------- telegrambots-abilities/pom.xml | 14 --------- telegrambots-chat-session-bot/pom.xml | 14 --------- telegrambots-extensions/pom.xml | 14 --------- telegrambots-meta/pom.xml | 14 --------- telegrambots-spring-boot-starter/pom.xml | 14 --------- telegrambots/pom.xml | 29 +++++++++---------- .../generated/LibraryVersion.java | 4 +++ .../updatesreceivers/DefaultWebhook.java | 23 ++++++++++++++- 9 files changed, 40 insertions(+), 100 deletions(-) create mode 100644 telegrambots/src/main/java-templates/org/telegram/telegrambots/generated/LibraryVersion.java diff --git a/pom.xml b/pom.xml index ff9a6ce5..db6fc6ab 100644 --- a/pom.xml +++ b/pom.xml @@ -156,20 +156,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index e496e171..9d549813 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -116,20 +116,6 @@ maven-surefire-plugin 3.0.0-M3 - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml index 84834dcc..7b992ab7 100644 --- a/telegrambots-chat-session-bot/pom.xml +++ b/telegrambots-chat-session-bot/pom.xml @@ -107,20 +107,6 @@ maven-surefire-plugin 3.0.0-M3 - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index 26e835ec..727c3de6 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -91,20 +91,6 @@ maven-surefire-plugin 3.0.0-M3 - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index c95ecee0..16b97867 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -123,20 +123,6 @@ ${project.build.directory}/test-classes ${project.basedir}/src/main/java - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index 083abae9..20361c86 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -114,20 +114,6 @@ ${project.build.directory}/test-classes ${project.basedir}/src/main/java - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index a8c418e7..667dbb88 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -70,7 +70,7 @@ UTF-8 UTF-8 - 2.29.1 + 2.30.1 1.19.3 4.5.10 20180813 @@ -194,20 +194,6 @@ maven-surefire-plugin 3.0.0-M3 - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - org.sonatype.plugins nexus-staging-maven-plugin @@ -325,6 +311,19 @@ + + org.codehaus.mojo + templating-maven-plugin + 1.0.0 + + + filtering-java-templates + + filter-sources + + + + diff --git a/telegrambots/src/main/java-templates/org/telegram/telegrambots/generated/LibraryVersion.java b/telegrambots/src/main/java-templates/org/telegram/telegrambots/generated/LibraryVersion.java new file mode 100644 index 00000000..202d2c00 --- /dev/null +++ b/telegrambots/src/main/java-templates/org/telegram/telegrambots/generated/LibraryVersion.java @@ -0,0 +1,4 @@ +package org.telegram.telegrambots.generated; +public final class LibraryVersion { + public static final String VERSION = "${project.version}"; +} \ No newline at end of file diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultWebhook.java b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultWebhook.java index 4a8c4d31..0cb5cbf4 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultWebhook.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultWebhook.java @@ -2,9 +2,11 @@ package org.telegram.telegrambots.updatesreceivers; import com.google.inject.Inject; +import java.util.LinkedHashMap; import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.grizzly.ssl.SSLContextConfigurator; import org.glassfish.grizzly.ssl.SSLEngineConfigurator; +import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.server.ResourceConfig; @@ -50,8 +52,12 @@ public class DefaultWebhook implements Webhook { public void startServer() throws TelegramApiRequestException { ResourceConfig rc = new ResourceConfig(); - rc.register(restApi); + rc.register(new SpecificBinder(restApi, RestApi.class)); rc.register(JacksonFeature.class); + rc.register(RestApi.class); + rc.setProperties(new LinkedHashMap() {{ + put(org.glassfish.jersey.server.ServerProperties.PROCESSING_RESPONSE_ERRORS_ENABLED, true); + }}); final HttpServer grizzlyServer; if (keystoreServerFile != null && keystoreServerPwd != null) { @@ -84,4 +90,19 @@ public class DefaultWebhook implements Webhook { throw new TelegramApiRequestException("Can't find or access server keystore file."); } } + + public static class SpecificBinder extends AbstractBinder { + private Object object; + private Class clazz; + + public SpecificBinder(Object object, Class clazz) { + this.object = object; + this.clazz = clazz; + } + + @Override + public void configure() { + bind(object).to(clazz); + } + } }