Fix remote DevTools' support for adding and removing classes
Previously, remote DevTools only correctly supported modifying existing classes. New classes that were added would be missed, and deleted classes could cause a failure as they would be found by component scanning but hidden by RestartClassLoader. This commit introduces a DevTools-specific ResourcePatternResolver that is installed as the application context's resource loader. This custom resolver is aware of the files that have been added and deleted and modifies the result returned from getResource and getResources accordingly. New intergration tests have been introduced to verify DevTools' behaviour. The tests cover four scenarios: - Adding a new controller - Removing an existing controller - Adding a request mapping to a controller - Removing a request mapping from a controller These four scenarios are tested with: - DevTools updating a local application - DevTools updating a remote application packaged in a jar file - DevTools updating a remote application that's been exploded Closes gh-7379
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License 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.example;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class ControllerOne {
|
||||
|
||||
@RequestMapping("/one")
|
||||
public String one() {
|
||||
return "one";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License 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.example;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.system.EmbeddedServerPortFileWriter;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DevToolsTestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(DevToolsTestApplication.class)
|
||||
.listeners(new EmbeddedServerPortFileWriter("target/server.port"))
|
||||
.run(args);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user