Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 08c76cf

Browse files
author
Tracy Boehrer
committed
Re-added bot-integration-spring. Using this module in samples. Cleaned up samples.
1 parent ac36d29 commit 08c76cf

File tree

37 files changed

+321
-1333
lines changed

37 files changed

+321
-1333
lines changed
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.microsoft.bot.sample.inspection;
4+
package com.microsoft.bot.integration;
55

66
import com.microsoft.bot.builder.ConversationState;
7-
import com.microsoft.bot.builder.Storage;
87
import com.microsoft.bot.builder.UserState;
98
import com.microsoft.bot.builder.inspection.InspectionMiddleware;
109
import com.microsoft.bot.builder.inspection.InspectionState;
1110
import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials;
12-
import com.microsoft.bot.integration.BotFrameworkHttpAdapter;
13-
import com.microsoft.bot.integration.Configuration;
1411

1512
/**
1613
* A BotFrameworkHttpAdapter that use InspectionMiddleware to forward message and state information.
14+
*
15+
* <p>See the Inspection sample for details on how this is used.</p>
1716
*/
1817
public class AdapterWithInspection extends BotFrameworkHttpAdapter {
1918
/**
2019
* Uses InspectionMiddleware to track ConversationState and UserState.
2120
*
22-
* @param configuration The Configuration {@link BotDependencyConfiguration#getConfiguration()}
23-
* @param inspectionState The InspectionState {@link Application#getInspectionState(Storage)}
24-
* @param userState The UserState {@link BotDependencyConfiguration#getUserState(Storage)}
25-
* @param conversationState The ConversationState {@link BotDependencyConfiguration#getConversationState(Storage)}
21+
* @param configuration The Configuration
22+
* @param inspectionState The InspectionState
23+
* @param userState The UserState
24+
* @param conversationState The ConversationState
2625
*/
2726
public AdapterWithInspection(Configuration configuration,
2827
InspectionState inspectionState,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<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/xsd/maven-4.0.0.xsd">
2+
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>com.microsoft.bot</groupId>
7+
<artifactId>bot-java</artifactId>
8+
<version>4.0.0-SNAPSHOT</version>
9+
<relativePath>../../pom.xml</relativePath>
10+
</parent>
11+
12+
<artifactId>bot-integration-spring</artifactId>
13+
<packaging>jar</packaging>
14+
15+
<name>${project.groupId}:${project.artifactId}</name>
16+
<description>Bot Framework Integration Spring</description>
17+
<url>https://dev.botframework.com/</url>
18+
19+
<licenses>
20+
<license>
21+
<name>MIT License</name>
22+
<url>http://www.opensource.org/licenses/mit-license.php</url>
23+
</license>
24+
</licenses>
25+
26+
<developers>
27+
<developer>
28+
<name>Bot Framework Development</name>
29+
<email></email>
30+
<organization>Microsoft</organization>
31+
<organizationUrl>https://dev.botframework.com/</organizationUrl>
32+
</developer>
33+
</developers>
34+
35+
<scm>
36+
<connection>scm:git:https://github.com/Microsoft/botbuilder-java</connection>
37+
<developerConnection>scm:git:https://github.com/Microsoft/botbuilder-java</developerConnection>
38+
<url>https://github.com/Microsoft/botbuilder-java</url>
39+
</scm>
40+
41+
<properties>
42+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
43+
<maven.deploy.skip>false</maven.deploy.skip>
44+
</properties>
45+
46+
<dependencies>
47+
<dependency>
48+
<groupId>junit</groupId>
49+
<artifactId>junit</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.slf4j</groupId>
53+
<artifactId>slf4j-api</artifactId>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-starter-web</artifactId>
59+
<version>2.1.8.RELEASE</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.springframework.boot</groupId>
63+
<artifactId>spring-boot-starter-test</artifactId>
64+
<version>2.1.8.RELEASE</version>
65+
<scope>test</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.springframework</groupId>
69+
<artifactId>spring-core</artifactId>
70+
<version>5.1.9.RELEASE</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.springframework</groupId>
74+
<artifactId>spring-beans</artifactId>
75+
<version>5.1.9.RELEASE</version>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.springframework.boot</groupId>
79+
<artifactId>spring-boot</artifactId>
80+
<version>2.1.8.RELEASE</version>
81+
<scope>compile</scope>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>com.microsoft.bot</groupId>
86+
<artifactId>bot-integration-core</artifactId>
87+
</dependency>
88+
</dependencies>
89+
90+
<profiles>
91+
<profile>
92+
<id>build</id>
93+
<activation>
94+
<activeByDefault>true</activeByDefault>
95+
</activation>
96+
<build>
97+
<plugins>
98+
<plugin>
99+
<groupId>org.eluder.coveralls</groupId>
100+
<artifactId>coveralls-maven-plugin</artifactId>
101+
<configuration>
102+
<repoToken>yourcoverallsprojectrepositorytoken</repoToken>
103+
</configuration>
104+
</plugin>
105+
<plugin>
106+
<groupId>org.codehaus.mojo</groupId>
107+
<artifactId>cobertura-maven-plugin</artifactId>
108+
<configuration>
109+
<outputDirectory>../../cobertura-report/bot-integration-spring</outputDirectory>
110+
<format>xml</format>
111+
<maxmem>256m</maxmem>
112+
<!-- aggregated reports for multi-module projects -->
113+
<aggregate>true</aggregate>
114+
<check />
115+
</configuration>
116+
</plugin>
117+
</plugins>
118+
</build>
119+
</profile>
120+
</profiles>
121+
</project>
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.microsoft.bot.sample.proactive;
4+
package com.microsoft.bot.integration.spring;
55

66
import com.microsoft.bot.builder.Bot;
77
import com.microsoft.bot.connector.authentication.AuthenticationException;
@@ -20,10 +20,11 @@
2020
import java.util.concurrent.CompletionException;
2121

2222
/**
23-
* This is the controller that will receive incoming Channel Activity messages.
23+
* This is the default controller that will receive incoming Channel Activity messages.
2424
*
25-
* <p>This class provides a route for the "/api/messages" path. Additional routes
26-
* could be supplied. For example, to handle proactive messages.</p>
25+
* <p>This controller is suitable in most cases. Bots that want to use this controller
26+
* should do so by using the @Import({BotController.class}) annotation. See any of the
27+
* samples Application class for an example.</p>
2728
*/
2829
@RestController
2930
public class BotController {
@@ -37,24 +38,22 @@ public class BotController {
3738
/**
3839
* The BotFrameworkHttpAdapter to use. Note is is provided by dependency
3940
* injection via the constructor.
40-
*
41-
* See DefaultDependencyConfiguration#getBotFrameworkHttpAdaptor(Configuration).
4241
*/
4342
private final BotFrameworkHttpAdapter adapter;
4443

4544
/**
4645
* The BotFrameworkHttpAdapter to use. Note is is provided by dependency
4746
* injection via the constructor.
48-
*
49-
* See DefaultDependencyConfiguration#getBot.
5047
*/
5148
private final Bot bot;
5249

5350
/**
54-
* Autowires Spring to use this constructor for creation.
51+
* Spring will use this constructor for creation.
52+
*
53+
* <p>The Bot application should define class that implements {@link Bot} and
54+
* annotate it with @Component.</p>
5555
*
56-
* See DefaultDependencyConfiguration#getBotFrameworkHttpAdaptor(Configuration).
57-
* See DefaultDependencyConfiguration#getBot.
56+
* @see BotDependencyConfiguration
5857
*
5958
* @param withAdapter The BotFrameworkHttpAdapter to use.
6059
* @param withBot The Bot to use.
Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.microsoft.bot.sample.suggestedactions;
4+
package com.microsoft.bot.integration.spring;
55

66
import com.microsoft.bot.builder.ConversationState;
77
import com.microsoft.bot.builder.MemoryStorage;
88
import com.microsoft.bot.builder.Storage;
99
import com.microsoft.bot.builder.UserState;
10+
import com.microsoft.bot.builder.inspection.InspectionState;
1011
import com.microsoft.bot.connector.authentication.ChannelProvider;
1112
import com.microsoft.bot.connector.authentication.CredentialProvider;
1213
import com.microsoft.bot.integration.BotFrameworkHttpAdapter;
1314
import com.microsoft.bot.integration.ClasspathPropertiesConfiguration;
1415
import com.microsoft.bot.integration.Configuration;
1516
import com.microsoft.bot.integration.ConfigurationChannelProvider;
1617
import com.microsoft.bot.integration.ConfigurationCredentialProvider;
17-
import org.springframework.beans.factory.annotation.Autowired;
1818
import org.springframework.context.annotation.Bean;
1919

2020
/**
@@ -46,9 +46,11 @@ public Configuration getConfiguration() {
4646
* By default, it uses the {@link ConfigurationCredentialProvider} class.
4747
* Default scope of Singleton.
4848
*
49+
* @param configuration The Configuration object to read from.
4950
* @return A CredentialProvider object.
51+
*
52+
* @see #getConfiguration()
5053
*/
51-
@Autowired
5254
@Bean
5355
public CredentialProvider getCredentialProvider(Configuration configuration) {
5456
return new ConfigurationCredentialProvider(configuration);
@@ -60,9 +62,11 @@ public CredentialProvider getCredentialProvider(Configuration configuration) {
6062
* By default, it uses the {@link ConfigurationChannelProvider} class.
6163
* Default scope of Singleton.
6264
*
65+
* @param configuration The Configuration object to read from.
6366
* @return A ChannelProvider object.
67+
*
68+
* @see #getConfiguration()
6469
*/
65-
@Autowired
6670
@Bean
6771
public ChannelProvider getChannelProvider(Configuration configuration) {
6872
return new ConfigurationChannelProvider(configuration);
@@ -74,16 +78,20 @@ public ChannelProvider getChannelProvider(Configuration configuration) {
7478
* By default, it uses the {@link BotFrameworkHttpAdapter} class.
7579
* Default scope of Singleton.
7680
*
81+
* @param configuration The Configuration object to read from.
7782
* @return A BotFrameworkHttpAdapter object.
83+
*
84+
* @see #getConfiguration()
7885
*/
79-
@Autowired
8086
@Bean
8187
public BotFrameworkHttpAdapter getBotFrameworkHttpAdaptor(Configuration configuration) {
8288
return new BotFrameworkHttpAdapter(configuration);
8389
}
8490

8591
/**
8692
* Returns a {@link Storage} object.
93+
* Default scope of Singleton.
94+
*
8795
* @return A Storage object.
8896
*/
8997
@Bean
@@ -93,23 +101,37 @@ public Storage getStorage() {
93101

94102
/**
95103
* Returns a ConversationState object.
104+
* Default scope of Singleton.
105+
*
96106
* @param storage The Storage object to use.
97107
* @return A ConversationState object.
98108
*/
99-
@Autowired
100109
@Bean
101110
public ConversationState getConversationState(Storage storage) {
102111
return new ConversationState(storage);
103112
}
104113

105114
/**
106115
* Returns a UserState object.
116+
* Default scope of Singleton.
117+
*
107118
* @param storage The Storage object to use.
108119
* @return A UserState object.
109120
*/
110-
@Autowired
111121
@Bean
112122
public UserState getUserState(Storage storage) {
113123
return new UserState(storage);
114124
}
125+
126+
/**
127+
* Creates an InspectionState used by {@link com.microsoft.bot.builder.inspection.InspectionMiddleware}.
128+
* Default scope of Singleton.
129+
*
130+
* @param storage The Storage to use. {@link BotDependencyConfiguration#getStorage()}
131+
* @return An InspectionState object that uses the specified storage.
132+
*/
133+
@Bean
134+
public InspectionState getInspectionState(Storage storage) {
135+
return new InspectionState(storage);
136+
}
115137
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for
3+
// license information.
4+
5+
/**
6+
* This package contains the classes for bot-integration-spring.
7+
*/
8+
package com.microsoft.bot.integration.spring;

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
<module>libraries/bot-ai-qna</module>
367367
<module>libraries/bot-applicationinsights</module>
368368
<module>libraries/bot-azure</module>
369+
<module>libraries/bot-integration-spring</module>
369370

370371
<module>samples/servlet-echo</module>
371372
<module>samples/02.echo-bot</module>

0 commit comments

Comments
 (0)