-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added locale and audioplayer directives
- Loading branch information
Brendan Clement
committed
Nov 16, 2016
1 parent
121336d
commit d52a5f4
Showing
113 changed files
with
5,104 additions
and
593 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.amazon.alexa</groupId> | ||
<artifactId>alexa-skills-kit</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.2</version> | ||
<name>Alexa Skills Kit</name> | ||
<description>Contains classes used by the Alexa Skills Kit.</description> | ||
<url>http://developer.amazon.com/ask</url> | ||
<licenses> | ||
<license> | ||
<name>The Apache License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
<developers> | ||
<developer> | ||
<name>Alexa Skills Kit</name> | ||
<email>dis-sdk-team@amazon.com</email> | ||
<organization>Alexa</organization> | ||
<organizationUrl>http://developer.amazon.com/ask</organizationUrl> | ||
</developer> | ||
</developers> | ||
<scm> | ||
<connection>scm:git:https://github.com/amzn/alexa-skills-kit-java.git</connection> | ||
<developerConnection>scm:git:https://github.com/amzn/alexa-skills-kit-java.git</developerConnection> | ||
<url>https://github.com/amzn/alexa-skills-kit-java.git</url> | ||
</scm> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.0.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>1.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-lambda-java-core</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.17</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>1.7.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
<forceJavacCompilerUse>true</forceJavacCompilerUse> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>publishing</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
<version>1.5.1</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<serverId>sonatype-nexus-staging</serverId> | ||
<nexusUrl>https://oss.sonatype.org</nexusUrl> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
except in compliance with the License. A copy of the License is located at | ||
http://aws.amazon.com/apache2.0/ | ||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.speech.json; | ||
|
||
import java.io.IOException; | ||
|
||
import com.amazon.speech.speechlet.Context; | ||
import com.amazon.speech.speechlet.State; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
|
||
class ContextDeserializer extends StdDeserializer<Context> { | ||
ContextDeserializer() { | ||
super(Context.class); | ||
} | ||
|
||
@Override | ||
public Context deserialize(JsonParser parser, DeserializationContext context) | ||
throws IOException { | ||
ObjectMapper underlyingMapper = ((ObjectMapper) parser.getCodec()); | ||
JsonNode messageNode = parser.readValueAsTree(); | ||
Context.Builder contextBuilder = Context.builder(); | ||
|
||
for (SerializedInterface interfaceName : SerializedInterface.values()) { | ||
if (messageNode.has(interfaceName.name())) { | ||
State<?> state = | ||
underlyingMapper.convertValue(messageNode.get(interfaceName.name()), | ||
interfaceName.getStateClass()); | ||
contextBuilder.addState(state); | ||
} | ||
} | ||
|
||
return contextBuilder.build(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
except in compliance with the License. A copy of the License is located at | ||
http://aws.amazon.com/apache2.0/ | ||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.speech.json; | ||
|
||
import java.io.IOException; | ||
|
||
import com.amazon.speech.speechlet.Context; | ||
import com.amazon.speech.speechlet.State; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
|
||
class ContextSerializer extends StdSerializer<Context> { | ||
ContextSerializer() { | ||
super(Context.class); | ||
} | ||
|
||
@Override | ||
public void serialize(Context context, JsonGenerator jgen, SerializerProvider provider) | ||
throws IOException { | ||
jgen.writeStartObject(); | ||
|
||
for (SerializedInterface interfaceName : SerializedInterface.values()) { | ||
if (context.hasState(interfaceName.getInterfaceClass())) { | ||
@SuppressWarnings("unchecked") | ||
State<?> state = context.getState(interfaceName.getInterfaceClass(), State.class); | ||
jgen.writeFieldName(interfaceName.name()); | ||
jgen.writeObject(state); | ||
} | ||
} | ||
|
||
jgen.writeEndObject(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
except in compliance with the License. A copy of the License is located at | ||
http://aws.amazon.com/apache2.0/ | ||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.speech.json; | ||
|
||
import com.amazon.speech.speechlet.Interface; | ||
import com.amazon.speech.speechlet.State; | ||
import com.amazon.speech.speechlet.interfaces.audioplayer.AudioPlayerInterface; | ||
import com.amazon.speech.speechlet.interfaces.audioplayer.AudioPlayerState; | ||
import com.amazon.speech.speechlet.interfaces.system.SystemInterface; | ||
import com.amazon.speech.speechlet.interfaces.system.SystemState; | ||
|
||
enum SerializedInterface { | ||
AudioPlayer(AudioPlayerInterface.class, AudioPlayerState.class), | ||
System(SystemInterface.class, SystemState.class); | ||
|
||
private final Class<? extends Interface> interfaceClass; | ||
private final Class<? extends State> stateClass; | ||
|
||
SerializedInterface(final Class<? extends Interface> interfaceClass, | ||
final Class<? extends State> stateClass) { | ||
this.interfaceClass = interfaceClass; | ||
this.stateClass = stateClass; | ||
} | ||
|
||
protected <T extends Interface> Class<T> getInterfaceClass() { | ||
return (Class<T>) interfaceClass; | ||
} | ||
|
||
protected <T extends State> Class<T> getStateClass() { | ||
return (Class<T>) stateClass; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/com/amazon/speech/json/SpeechletRequestBeanDeserializerModifier.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
except in compliance with the License. A copy of the License is located at | ||
http://aws.amazon.com/apache2.0/ | ||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.speech.json; | ||
|
||
import com.amazon.speech.speechlet.Context; | ||
import com.amazon.speech.speechlet.SupportedInterfaces; | ||
import com.fasterxml.jackson.databind.BeanDescription; | ||
import com.fasterxml.jackson.databind.DeserializationConfig; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; | ||
|
||
class SpeechletRequestBeanDeserializerModifier extends BeanDeserializerModifier { | ||
@Override | ||
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, | ||
BeanDescription beanDesc, JsonDeserializer<?> deserializer) { | ||
if (Context.class.isAssignableFrom(beanDesc.getBeanClass())) { | ||
return new ContextDeserializer(); | ||
} else if (SupportedInterfaces.class.isAssignableFrom(beanDesc.getBeanClass())) { | ||
return new SupportedInterfacesDeserializer(); | ||
} else { | ||
return deserializer; | ||
} | ||
} | ||
} |
Oops, something went wrong.