本文整理汇总了Java中com.amazon.speech.speechlet.servlet.SpeechletServlet类的典型用法代码示例。如果您正苦于以下问题:Java SpeechletServlet类的具体用法?Java SpeechletServlet怎么用?Java SpeechletServlet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpeechletServlet类属于com.amazon.speech.speechlet.servlet包,在下文中一共展示了SpeechletServlet类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alexaServlet
import com.amazon.speech.speechlet.servlet.SpeechletServlet; //导入依赖的package包/类
/**
* Registers the {@link SpeechletServlet} at the application.
*
* @param speechlet Speechlet.
* @return Registration.
*/
@Bean
public ServletRegistrationBean alexaServlet(WarehouseSpeechlet speechlet) {
SpeechletServlet speechServlet = new SpeechletServlet();
speechServlet.setSpeechlet(speechlet);
ServletRegistrationBean servlet = new ServletRegistrationBean(speechServlet, "/alexa");
servlet.setName("alexa");
return servlet;
}
示例2: SpeechletServletDispatcher
import com.amazon.speech.speechlet.servlet.SpeechletServlet; //导入依赖的package包/类
public SpeechletServletDispatcher(SpeechletHandlerHolder handler) {
this.handler = handler;
try {
Field field = SpeechletServlet.class.getDeclaredField("speechletRequestHandler");
field.setAccessible(true);
field.set(this, new LoggingServletSpeechletRequestHandler());
field.setAccessible(false);
}catch (Exception e){
throw new RuntimeException("Could set logging aspect!", e);
}
this.setSpeechlet(this);
}
示例3: configure
import com.amazon.speech.speechlet.servlet.SpeechletServlet; //导入依赖的package包/类
private void configure(ServletContext ctx, String endpoint, SpeechletHandlerHolder handler) {
final SpeechletServlet servlet = new SpeechletServletDispatcher(handler);
ServletRegistration.Dynamic serviceServlet = ctx.addServlet("SpeechletServlet_" + (servletCount++), servlet);
serviceServlet.addMapping(endpoint);
}
示例4: main
import com.amazon.speech.speechlet.servlet.SpeechletServlet; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
System.setProperty(Sdk.DISABLE_REQUEST_SIGNATURE_CHECK_SYSTEM_PROPERTY, "true");
String envPort = System.getenv("PORT");
int port = envPort == null || envPort.isEmpty() ? 8000 : Integer.valueOf(envPort);
// Configure server and its associated servlets
Server server = new Server(port);
ServletContextHandler context = new ServletContextHandler();
context.addEventListener(new GuiceServletContextListener() {
@Override
protected Injector getInjector() {
Module services = new AbstractModule() {
@Override
protected void configure() {
bind(SpeechRouter.class).toProvider(new Provider<SpeechRouter>() {
@Inject Injector injector;
@Override
public SpeechRouter get() {
try {
return SpeechRouter.create(injector, "rottentomatoes");
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}).in(Singleton.class);
bind(AlexaSessionProvider.class).in(RequestScoped.class);
bind(RequestContextProvider.class).in(RequestScoped.class);
bind(SpeechletServlet.class).toProvider(new Provider<SpeechletServlet>() {
@Inject SpeechRouter router;
@Inject Injector injector;
@Override
public SpeechletServlet get() {
SpeechletServlet servlet = new SpeechletServlet();
servlet.setSpeechlet(new RoutingSpeechlet(router, injector));
return servlet;
}
}).in(Singleton.class);
}
};
return Guice.createInjector(services, new ServletModule() {
@Override
protected void configureServlets() {
serve("/sample-utterances").with(SampleUtterancesServlet.class);
serve("/intent-schema").with(IntentSchemaServlet.class);
serve("/rotten-tomatoes").with(SpeechletServlet.class);
}
});
}
});
context.addFilter(GuiceFilter.class, "/*", null);
context.addServlet(DefaultServlet.class, "/");
server.setHandler(context);
server.start();
server.join();
}
示例5: createServlet
import com.amazon.speech.speechlet.servlet.SpeechletServlet; //导入依赖的package包/类
private static SpeechletServlet createServlet(final Speechlet speechlet) {
SpeechletServlet servlet = new SpeechletServlet();
servlet.setSpeechlet(speechlet);
return servlet;
}
示例6: createServlet
import com.amazon.speech.speechlet.servlet.SpeechletServlet; //导入依赖的package包/类
private static SpeechletServlet createServlet(final Speechlet speechlet) {
SpeechletServlet servlet = new SpeechletServlet();
servlet.setSpeechlet(speechlet);
return servlet;
}