Streamline and refactor the azure and the azure-web adapters.

- Add SCF/Azure Gradle sample and docs.
- Move the function-azure-di-samples into standalone projects.
 - Apply the name convetion and project structure for the SCF adaptes.
   E.g.  function-sample-azure-XXX projects under the spring-cloud-function-samples root.
 - Remove the redudant samples.
 - Improve the samples docs and the Adapter generic docs.
- Streamline docs.
- Add azure web adapter sample and README.
- Add Spring Azure Functions banner for azure and azure web adapters.
- azure-web adapter fixes:
  - Fix issues in serverles-web ProxyHttpServletResponse implementation.
  - Remove the custom FunctionClassUtils utils in favor of scf-context/util/FunctionClassUtils.
- Remove redundant files.
- Add FunctionInvoker deprecation annotations.
- Extend the time trigger sample with Retry policies example.
This commit is contained in:
Christian Tzolov
2023-07-14 18:46:42 +02:00
parent 64f57bcef8
commit 6299a5366b
88 changed files with 1834 additions and 1312 deletions

View File

@@ -0,0 +1,15 @@
package com.example.azure.web;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@EnableJpaRepositories
public class AzureWebDemoApplication {
public static void main(String[] args) {
SpringApplication.run(AzureWebDemoApplication.class, args);
}
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright 2023-2023 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
*
* https://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.azure.web;
import java.util.Objects;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
/**
*
* @author Christian Tzolov
*/
@Table(name = "COUNTRIES")
@Entity
public class Country {
@Id
@GeneratedValue
private Long id;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Country country = (Country) o;
return id == country.id && name.equals(country.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
@Override
public String toString() {
return "Country{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2023-2023 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
*
* https://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.azure.web;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author Christian Tzolov
*/
@RestController
public class CountryController {
@Autowired
private CountryRepository countryRepository;
@GetMapping("/")
public String index() {
return "Country Count: " + countryRepository.count();
}
@GetMapping("/countries")
public String allCountries() {
String countries = this.countryRepository.findAll().stream()
.map(country -> country.toString())
.collect(Collectors.joining());
return "Countries: " + countries;
}
@PostMapping(path = "/countries")
public Country addCountry(@RequestBody Country country) {
if (!StringUtils.hasText(country.getName())) {
return null;
}
return this.countryRepository.save(country);
}
@GetMapping("/countries/{id}")
public Country countryById(@PathVariable Integer id) {
return this.countryRepository.findById(id).get();
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2023-2023 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
*
* https://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.azure.web;
import org.springframework.data.jpa.repository.JpaRepository;
/**
*
* @author Christian Tzolov
*/
public interface CountryRepository extends JpaRepository<Country, Integer> {
}