├── .github └── workflows │ └── integrationTest.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── database ├── spring-cloud-stream-binder-oracle-txeventq │ ├── .gitignore │ ├── LICENSE.txt │ ├── README.md │ ├── THIRD_PARTY_LICENSES.txt │ ├── pom.xml │ ├── samples │ │ ├── BatchProducerTest.java │ │ ├── ConsumerBatchTest.java │ │ ├── DemoPartition.java │ │ ├── DemoTests.java │ │ ├── ErrorHandlerTest.java │ │ ├── MultipleConsumerTest.java │ │ ├── ProducerErrorChannelTest.java │ │ └── ProducerNativeTest.java │ ├── scripts │ │ └── deploy │ ├── spring-cloud-stream-binder-txeventq-sample │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── cloud │ │ │ │ │ └── stream │ │ │ │ │ └── binder │ │ │ │ │ └── sample │ │ │ │ │ ├── StreamConfiguration.java │ │ │ │ │ ├── TxEventQSampleApp.java │ │ │ │ │ └── WordSupplier.java │ │ │ └── resources │ │ │ │ └── application.yaml │ │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── stream │ │ │ │ └── binder │ │ │ │ └── sample │ │ │ │ └── TxEventQSampleAppTest.java │ │ │ └── resources │ │ │ └── init.sql │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── stream │ │ │ │ └── binder │ │ │ │ ├── JMSMessageChannelBinder.java │ │ │ │ ├── TxEventQQueueProvisioner.java │ │ │ │ ├── config │ │ │ │ ├── JmsBinderAutoConfiguration.java │ │ │ │ ├── JmsBinderGlobalConfiguration.java │ │ │ │ ├── JmsBindingProperties.java │ │ │ │ ├── JmsConsumerProperties.java │ │ │ │ ├── JmsExtendedBindingProperties.java │ │ │ │ ├── JmsProducerProperties.java │ │ │ │ └── TxEventQJmsConfiguration.java │ │ │ │ ├── plsql │ │ │ │ └── OracleDBUtils.java │ │ │ │ ├── provisioning │ │ │ │ ├── JmsConsumerDestination.java │ │ │ │ └── JmsProducerDestination.java │ │ │ │ ├── serialize │ │ │ │ ├── CustomSerializationMessageConverter.java │ │ │ │ ├── Deserializer.java │ │ │ │ └── Serializer.java │ │ │ │ └── utils │ │ │ │ ├── AnonymousNamingStrategy.java │ │ │ │ ├── Base64UrlNamingStrategy.java │ │ │ │ ├── DestinationNameResolver.java │ │ │ │ ├── JmsMessageDrivenChannelAdapter.java │ │ │ │ ├── JmsMessageDrivenChannelAdapterFactory.java │ │ │ │ ├── JmsSendingMessageHandlerFactory.java │ │ │ │ ├── ListenerContainerFactory.java │ │ │ │ ├── MessageRecoverer.java │ │ │ │ ├── PartitionAwareJmsSendingMessageHandler.java │ │ │ │ ├── RepublishMessageRecoverer.java │ │ │ │ ├── SpecCompliantJmsHeaderMapper.java │ │ │ │ ├── TEQBatchMessageListener.java │ │ │ │ ├── TEQBatchMessageListenerContainer.java │ │ │ │ ├── TEQMessageListenerContainer.java │ │ │ │ ├── TxEventQBinderHeaderConstants.java │ │ │ │ ├── TxEventQMessageBuilder.java │ │ │ │ └── TxEventQUtils.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring.binders │ │ └── test │ │ ├── java │ │ ├── com │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── stream │ │ │ │ └── binder │ │ │ │ ├── TEQPartitionIT.java │ │ │ │ ├── TEQSpringBootIT.java │ │ │ │ ├── TxEventQTestBinder.java │ │ │ │ └── Util.java │ │ └── nativetests │ │ │ ├── TestObject.java │ │ │ ├── TestObjectDeserializer.java │ │ │ └── TestObjectSerializer.java │ │ └── resources │ │ └── init.sql └── starters │ ├── LICENSE.txt │ ├── Makefile │ ├── README.md │ ├── THIRD_PARTY_LICENSES.txt │ ├── oracle-spring-boot-json-data-tools │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── spring │ │ │ │ └── json │ │ │ │ ├── JsonCollectionsAutoConfiguration.java │ │ │ │ ├── jsonb │ │ │ │ ├── JSONB.java │ │ │ │ └── JSONBRowMapper.java │ │ │ │ └── kafka │ │ │ │ ├── OSONDeserializer.java │ │ │ │ ├── OSONKafkaSerializationFactory.java │ │ │ │ └── OSONSerializer.java │ │ └── resources │ │ │ └── META-INF │ │ │ ├── spring.factories │ │ │ └── spring │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ └── test │ │ └── java │ │ └── com │ │ └── oracle │ │ └── spring │ │ └── json │ │ ├── JsonCollectionsIT.java │ │ ├── jsonb │ │ └── JSONBTest.java │ │ └── test │ │ ├── Student.java │ │ └── StudentDetails.java │ ├── oracle-spring-boot-json-relational-duality-views │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── oracle │ │ │ └── spring │ │ │ └── json │ │ │ └── duality │ │ │ ├── annotation │ │ │ ├── AccessMode.java │ │ │ ├── JsonRelationalDualityView.java │ │ │ └── JsonRelationalDualityViewScan.java │ │ │ └── builder │ │ │ ├── Annotations.java │ │ │ ├── DualityViewBuilder.java │ │ │ ├── DualityViewScanner.java │ │ │ ├── RootSnippet.java │ │ │ ├── ScannerConfiguration.java │ │ │ └── ViewEntity.java │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── spring │ │ │ └── json │ │ │ └── duality │ │ │ ├── Application.java │ │ │ ├── JsonRelationalDualityClient.java │ │ │ ├── SpringBootDualityTest.java │ │ │ ├── builder │ │ │ └── DualityViewBuilderTest.java │ │ │ └── model │ │ │ ├── book │ │ │ ├── Book.java │ │ │ ├── Loan.java │ │ │ └── Member.java │ │ │ ├── employee │ │ │ ├── Employee.java │ │ │ ├── ManagerAdapter.java │ │ │ ├── ReportsAdapter.java │ │ │ └── SimpleEmployee.java │ │ │ ├── movie │ │ │ ├── Actor.java │ │ │ ├── Director.java │ │ │ ├── DirectorBio.java │ │ │ └── Movie.java │ │ │ ├── products │ │ │ ├── Order.java │ │ │ └── Product.java │ │ │ └── student │ │ │ └── Student.java │ │ └── resources │ │ ├── application.yaml │ │ ├── products.sql │ │ └── views │ │ ├── actor-create.sql │ │ ├── employee-create.sql │ │ ├── member-create-drop.sql │ │ ├── order-create.sql │ │ ├── student-create.sql │ │ └── student-update.sql │ ├── oracle-spring-boot-starter-aqjms │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── spring │ │ │ │ └── aqjms │ │ │ │ └── AqJmsAutoConfiguration.java │ │ └── resources │ │ │ └── META-INF │ │ │ ├── spring.factories │ │ │ └── spring │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ └── test │ │ └── java │ │ └── com │ │ └── oracle │ │ └── spring │ │ └── aqjms │ │ ├── AqJmsAutoConfigurationTest.java │ │ └── Config.java │ ├── oracle-spring-boot-starter-json-collections │ └── pom.xml │ ├── oracle-spring-boot-starter-okafka │ └── pom.xml │ ├── oracle-spring-boot-starter-samples │ ├── README.md │ ├── oracle-spring-boot-sample-json-duality │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── jsonduality │ │ │ │ │ ├── Course.java │ │ │ │ │ ├── CourseService.java │ │ │ │ │ ├── Enrollment.java │ │ │ │ │ ├── JSONDualitySampleApplication.java │ │ │ │ │ ├── LectureHall.java │ │ │ │ │ ├── Student.java │ │ │ │ │ └── StudentService.java │ │ │ └── resources │ │ │ │ └── application.yaml │ │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── jsonduality │ │ │ │ └── JSONDualitySampleApplicationTest.java │ │ │ └── resources │ │ │ └── init.sql │ ├── oracle-spring-boot-sample-json-events │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── jsonevents │ │ │ │ │ ├── JSONEventsSampleApp.java │ │ │ │ │ ├── OKafkaComponent.java │ │ │ │ │ ├── OKafkaConfiguration.java │ │ │ │ │ ├── SensorConsumer.java │ │ │ │ │ ├── SensorController.java │ │ │ │ │ ├── SensorEnricher.java │ │ │ │ │ ├── SensorEventParser.java │ │ │ │ │ ├── SensorEventProducer.java │ │ │ │ │ ├── SensorService.java │ │ │ │ │ ├── StationService.java │ │ │ │ │ └── model │ │ │ │ │ ├── Sensor.java │ │ │ │ │ ├── SensorEvent.java │ │ │ │ │ └── Station.java │ │ │ └── resources │ │ │ │ ├── application.yaml │ │ │ │ ├── log4j.properties │ │ │ │ └── ojdbc.properties │ │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── jsonevents │ │ │ │ └── JSONEventsSampleTest.java │ │ │ └── resources │ │ │ ├── init.sql │ │ │ └── txeventq.sql │ ├── oracle-spring-boot-sample-okafka │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── okafka │ │ │ │ │ ├── OKafkaComponent.java │ │ │ │ │ ├── OKafkaConfiguration.java │ │ │ │ │ ├── OKafkaSampleApp.java │ │ │ │ │ ├── OKafkaUtil.java │ │ │ │ │ ├── SampleConsumer.java │ │ │ │ │ └── SampleProducer.java │ │ │ └── resources │ │ │ │ ├── application.yaml │ │ │ │ ├── log4j.properties │ │ │ │ └── ojdbc.properties │ │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── okafka │ │ │ │ └── OKafkaSampleTest.java │ │ │ └── resources │ │ │ ├── init.sql │ │ │ └── weather_sensor_data.txt │ ├── oracle-spring-boot-sample-txeventqjms │ │ ├── README.md │ │ ├── consumer │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── txeventqjms │ │ │ │ │ └── consumer │ │ │ │ │ ├── ConsumerApplication.java │ │ │ │ │ └── service │ │ │ │ │ └── Consumer.java │ │ │ │ └── resources │ │ │ │ ├── application.yaml │ │ │ │ └── banner.txt │ │ ├── pom.xml │ │ ├── producer │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── txeventq │ │ │ │ │ └── producer │ │ │ │ │ ├── ProducerApplication.java │ │ │ │ │ ├── controller │ │ │ │ │ └── MessageController.java │ │ │ │ │ └── service │ │ │ │ │ └── Producer.java │ │ │ │ └── resources │ │ │ │ ├── application.yaml │ │ │ │ └── banner.txt │ │ └── sql │ │ │ └── setup.sql │ ├── oracle-spring-boot-sample-ucp-jpa │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── oracle │ │ │ │ │ └── database │ │ │ │ │ └── spring │ │ │ │ │ └── sample │ │ │ │ │ ├── Student.java │ │ │ │ │ ├── StudentController.java │ │ │ │ │ ├── StudentRepository.java │ │ │ │ │ └── UCPSampleApplication.java │ │ │ └── resources │ │ │ │ └── application.yaml │ │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── UCPSampleApplicationTest.java │ │ │ └── resources │ │ │ └── init.sql │ ├── oracle-spring-boot-sample-wallet │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── database │ │ │ │ └── spring │ │ │ │ └── oraclespringbootsamplewallet │ │ │ │ └── OracleSpringBootSampleWalletApplication.java │ │ │ └── resources │ │ │ └── application.yaml │ └── pom.xml │ ├── oracle-spring-boot-starter-ucp │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── spring │ │ │ │ └── ucp │ │ │ │ └── UCPAutoConfiguration.java │ │ └── resources │ │ │ └── META-INF │ │ │ ├── spring.factories │ │ │ └── spring │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ └── test │ │ └── java │ │ └── com │ │ └── oracle │ │ └── spring │ │ └── ucp │ │ ├── Config.java │ │ └── UCPAutoConfigurationTest.java │ ├── oracle-spring-boot-starter-wallet │ └── pom.xml │ ├── pom.xml │ └── scripts │ └── deploy ├── recipes └── hikariucp │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ ├── main │ ├── com │ │ └── oracle │ │ │ └── cloud │ │ │ └── recipes │ │ │ └── hikariucp │ │ │ ├── ConvertMsToSecondsInPropertiesRecipe.java │ │ │ └── ConvertMsToSecondsInYamlRecipe.java │ └── resources │ │ └── META-INF │ │ └── rewrite │ │ └── rewrite.yml │ └── test │ └── oracle │ └── com │ └── cloud │ └── recipes │ └── hikariucp │ └── ChangePropertyValueTest.java ├── sbom_generation.yaml ├── spring-cli ├── README .md ├── catalog │ └── project-catalog.yml └── projects │ └── obaas │ ├── .gitignore │ ├── LICENSE │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── restservice │ │ │ ├── Application.java │ │ │ ├── controller │ │ │ └── GreetingController.java │ │ │ └── model │ │ │ └── Greeting.java │ └── resources │ │ ├── application-local.yaml │ │ ├── application.yaml │ │ └── db │ │ └── changelog │ │ ├── controller.yaml │ │ ├── data.sql │ │ └── table.sql │ └── test │ └── java │ └── com │ └── example │ └── restservice │ └── greeting │ └── GreetingControllerTests.java └── spring-cloud-oci ├── LICENSE.txt ├── Makefile ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── docs ├── generate-docs.sh ├── pom.xml └── src │ └── main │ ├── asciidoc │ ├── Guardfile │ ├── _attributes.adoc │ ├── _configprops.adoc │ ├── adb.adoc │ ├── appendix.adoc │ ├── aqjms.adoc │ ├── configuration.adoc │ ├── core.adoc │ ├── email.adoc │ ├── function.adoc │ ├── genai.adoc │ ├── getting-started.adoc │ ├── ghpages.sh │ ├── index-docinfo.xml │ ├── index.adoc │ ├── jsoncollection.adoc │ ├── logging.adoc │ ├── nosql.adoc │ ├── notifications.adoc │ ├── queues.adoc │ ├── storage.adoc │ ├── streaming.adoc │ ├── ucp.adoc │ ├── vault.adoc │ └── wallet.adoc │ └── javadoc │ └── spring-javadoc.css ├── pom.xml ├── scripts ├── deploy └── version ├── spring-cloud-oci-adb ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── adb │ │ ├── AutonomousDb.java │ │ ├── AutonomousDbDetails.java │ │ └── AutonomousDbImpl.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── adb │ └── AutonomousDbImplTests.java ├── spring-cloud-oci-autoconfigure ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ ├── adb │ │ │ └── AutonomousDbAutoConfiguration.java │ │ │ ├── autoconfigure │ │ │ └── core │ │ │ │ ├── CompartmentProperties.java │ │ │ │ ├── CompartmentProviderAutoConfiguration.java │ │ │ │ ├── CredentialsProperties.java │ │ │ │ ├── CredentialsProvider.java │ │ │ │ ├── CredentialsProviderAutoConfiguration.java │ │ │ │ ├── RegionProperties.java │ │ │ │ └── RegionProviderAutoConfiguration.java │ │ │ ├── email │ │ │ ├── EmailDeliveryAutoConfiguration.java │ │ │ └── MailSenderProperties.java │ │ │ ├── function │ │ │ └── FunctionAutoConfiguration.java │ │ │ ├── genai │ │ │ ├── GenAIAutoConfiguration.java │ │ │ └── GenAIProperties.java │ │ │ ├── logging │ │ │ ├── LoggingAutoConfiguration.java │ │ │ └── LoggingProperties.java │ │ │ ├── nosql │ │ │ └── NoSQLAutoConfiguration.java │ │ │ ├── notification │ │ │ └── NotificationAutoConfiguration.java │ │ │ ├── queue │ │ │ └── QueueAutoConfiguration.java │ │ │ ├── storage │ │ │ └── StorageAutoConfiguration.java │ │ │ ├── streaming │ │ │ └── StreamingAutoConfiguration.java │ │ │ └── vault │ │ │ ├── VaultAutoConfiguration.java │ │ │ ├── VaultEnvironmentPostProcessor.java │ │ │ ├── VaultProperties.java │ │ │ ├── VaultPropertyLoader.java │ │ │ ├── VaultPropertySource.java │ │ │ └── VaultPropertySourceProperties.java │ └── resources │ │ └── META-INF │ │ ├── additional-spring-configuration-metadata.json │ │ ├── spring.factories │ │ └── spring │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ ├── autoconfigure │ ├── TestCommonConfigurationBeans.java │ └── core │ │ ├── CompartmentProviderAutoConfigurationTests.java │ │ ├── CredentialsProviderAutoConfigurationTests.java │ │ └── RegionProviderAutoConfigurationTests.java │ ├── email │ └── EmailDeliveryAutoConfigurationTests.java │ ├── function │ └── FunctionAutoConfigurationTests.java │ ├── logging │ └── LoggingAutoConfigurationTests.java │ ├── nosql │ └── NoSQLAutoConfigurationTests.java │ ├── notification │ └── NotificationAutoConfigurationTests.java │ ├── queue │ └── QueueAutoConfigurationTests.java │ ├── storage │ └── StorageAutoConfigurationTests.java │ ├── streaming │ └── StreamingAutoConfigurationTests.java │ └── vault │ └── VaultAutoConfigurationTests.java ├── spring-cloud-oci-core ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── core │ │ ├── compartment │ │ ├── CompartmentProvider.java │ │ └── StaticCompartmentProvider.java │ │ ├── region │ │ └── StaticRegionProvider.java │ │ └── util │ │ └── OCIObjectMapper.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── core │ ├── compartment │ └── CompartmentProviderTests.java │ ├── region │ └── RegionProviderTests.java │ └── util │ └── OCIObjectMapperTests.java ├── spring-cloud-oci-dependencies └── pom.xml ├── spring-cloud-oci-email ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── email │ │ ├── EmailDeliveryJavaMailSender.java │ │ └── EmailDeliveryMailSender.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── email │ ├── EmailDeliveryJavaMailSenderTest.java │ ├── EmailDeliveryMailSenderTest.java │ └── EmailTest.java ├── spring-cloud-oci-function ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── function │ │ ├── Function.java │ │ └── FunctionImpl.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── function │ └── FunctionImplTests.java ├── spring-cloud-oci-gen-ai ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── genai │ │ ├── ChatModel.java │ │ ├── ChatModelImpl.java │ │ ├── EmbeddingModel.java │ │ ├── EmbeddingModelImpl.java │ │ └── InferenceRequestType.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── genai │ ├── ChatModelTest.java │ └── EmbeddingModelTest.java ├── spring-cloud-oci-logging ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── logging │ │ ├── LogService.java │ │ └── LogServiceImpl.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── logging │ └── LogServiceImplTests.java ├── spring-cloud-oci-notification ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── notification │ │ ├── Notification.java │ │ └── NotificationImpl.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── notification │ └── NotificationImplTests.java ├── spring-cloud-oci-queue ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── queue │ │ ├── Queue.java │ │ └── QueueImpl.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── queue │ └── QueueImplTests.java ├── spring-cloud-oci-samples ├── README.md ├── pom.xml ├── spring-cloud-oci-adb-sample │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── adb │ │ │ └── springcloudociadbsample │ │ │ ├── AdbController.java │ │ │ ├── HelloController.java │ │ │ └── SpringCloudOciAdbSampleApplication.java │ │ └── resources │ │ └── application.properties ├── spring-cloud-oci-common-samples-utils │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── common │ │ │ └── util │ │ │ └── FileUtils.java │ │ └── test │ │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── sample │ │ └── common │ │ └── base │ │ └── SpringCloudSampleApplicationTestBase.java ├── spring-cloud-oci-email-sample │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── email │ │ │ │ └── springcloudemailsample │ │ │ │ ├── EmailService.java │ │ │ │ └── SpringCloudEmailSampleApplication.java │ │ └── resources │ │ │ └── application.yaml │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── email │ │ │ └── springcloudemailsample │ │ │ └── EmailIT.java │ │ └── resources │ │ └── attachment.txt ├── spring-cloud-oci-function-sample │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── function │ │ │ │ └── springcloudocifunctionsample │ │ │ │ ├── FunctionController.java │ │ │ │ ├── HelloController.java │ │ │ │ └── SpringCloudOciFunctionSampleApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── function │ │ │ └── springcloudocifunctionsample │ │ │ └── SpringCloudOciFunctionSampleApplicationTests.java │ │ └── resources │ │ └── application-test.properties ├── spring-cloud-oci-gen-ai-sample │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── genai │ │ │ │ └── springcloudocigenaisample │ │ │ │ ├── ChatModelController.java │ │ │ │ ├── EmbeddingModelController.java │ │ │ │ └── SpringCloudOciGenAISampleApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── genai │ │ │ └── springcloudocigenaisample │ │ │ ├── ChatIT.java │ │ │ ├── CohereChatIT.java │ │ │ ├── EmbeddingIT.java │ │ │ └── LLamaChatIT.java │ │ └── resources │ │ ├── application-chat-cohere.properties │ │ ├── application-chat-llama.properties │ │ └── application-embedding.properties ├── spring-cloud-oci-logging-sample │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── logging │ │ │ │ └── springcloudociloggingsample │ │ │ │ ├── HelloController.java │ │ │ │ ├── LoggingController.java │ │ │ │ └── SpringCloudOciLoggingSampleApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── logging │ │ │ └── springcloudociloggingsample │ │ │ └── SpringCloudOciLoggingSampleApplicationTests.java │ │ └── resources │ │ └── application-test.properties ├── spring-cloud-oci-nosql-sample │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── nosql │ │ │ │ └── springcloudnosqlsample │ │ │ │ ├── Book.java │ │ │ │ ├── BookController.java │ │ │ │ ├── BookRepository.java │ │ │ │ └── SpringCloudOciNoSQLSampleApplication.java │ │ └── resources │ │ │ └── application.yaml │ │ └── test │ │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── sample │ │ └── nosql │ │ └── springcloudnosqlsample │ │ └── NoSQLSampleApplicationIT.java ├── spring-cloud-oci-notification-sample │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── notification │ │ │ │ └── springcloudocinotificationsample │ │ │ │ ├── HelloController.java │ │ │ │ ├── NotificationController.java │ │ │ │ └── SpringCloudOciNotificationSampleApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── notification │ │ │ └── springcloudocinotificationsample │ │ │ └── SpringCloudOciNotificationSampleApplicationTests.java │ │ └── resources │ │ └── application-test.properties ├── spring-cloud-oci-queue-sample │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── queue │ │ │ │ └── springcloudociqueuesample │ │ │ │ ├── HelloController.java │ │ │ │ ├── QueueController.java │ │ │ │ └── SpringCloudOciQueueSampleApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── queue │ │ │ └── springcloudociqueuesample │ │ │ └── SpringCloudOciQueueSampleApplicationTests.java │ │ └── resources │ │ └── application-test.properties ├── spring-cloud-oci-storage-sample │ ├── README.md │ ├── images │ │ └── swagger-ui.png │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── storage │ │ │ │ └── springcloudocistoragesample │ │ │ │ ├── BucketController.java │ │ │ │ ├── HelloController.java │ │ │ │ ├── ImageController.java │ │ │ │ ├── ObjectController.java │ │ │ │ └── SpringCloudOciStorageSampleApplication.java │ │ └── resources │ │ │ └── application.yaml │ │ └── test │ │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── sample │ │ └── storage │ │ └── springcloudocistoragesample │ │ └── SpringCloudOciStorageSampleApplicationTests.java ├── spring-cloud-oci-streaming-sample │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── sample │ │ │ │ └── streaming │ │ │ │ └── springcloudocistreamingsample │ │ │ │ ├── HelloController.java │ │ │ │ ├── SpringCloudOciStreamingSampleApplication.java │ │ │ │ └── StreamingController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── streaming │ │ │ └── springcloudocistreamingsample │ │ │ └── SpringCloudOciStreamingSampleApplicationTests.java │ │ └── resources │ │ └── application-test.properties └── spring-cloud-oci-vault-sample │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── sample │ │ │ └── vault │ │ │ └── springcloudocivaultsample │ │ │ ├── SpringCloudOciVaultSampleApplication.java │ │ │ └── VaultController.java │ └── resources │ │ └── application.yaml │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── sample │ └── vault │ └── springcloudocivaultsample │ └── VaultTemplateIT.java ├── spring-cloud-oci-starters ├── pom.xml ├── spring-cloud-oci-starter-adb │ └── pom.xml ├── spring-cloud-oci-starter-email │ └── pom.xml ├── spring-cloud-oci-starter-function │ └── pom.xml ├── spring-cloud-oci-starter-gen-ai │ └── pom.xml ├── spring-cloud-oci-starter-logging │ └── pom.xml ├── spring-cloud-oci-starter-nosql │ └── pom.xml ├── spring-cloud-oci-starter-notification │ └── pom.xml ├── spring-cloud-oci-starter-queue │ └── pom.xml ├── spring-cloud-oci-starter-storage │ └── pom.xml ├── spring-cloud-oci-starter-streaming │ └── pom.xml ├── spring-cloud-oci-starter-vault │ └── pom.xml └── spring-cloud-oci-starter │ └── pom.xml ├── spring-cloud-oci-storage ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── oracle │ │ │ └── cloud │ │ │ └── spring │ │ │ └── storage │ │ │ ├── JacksonJSONStorageObjectConverter.java │ │ │ ├── OracleStorageProtocolResolver.java │ │ │ ├── OracleStorageResource.java │ │ │ ├── Storage.java │ │ │ ├── StorageContentTypeResolver.java │ │ │ ├── StorageContentTypeResolverImpl.java │ │ │ ├── StorageException.java │ │ │ ├── StorageImpl.java │ │ │ ├── StorageLocation.java │ │ │ ├── StorageObjectConverter.java │ │ │ └── StorageObjectMetadata.java │ └── resources │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── storage │ │ └── StorageContentTypeResolver.properties │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── storage │ ├── JacksonJSONStorageObjectConverterTests.java │ ├── OracleStorageProtocolResolverTests.java │ ├── OracleStorageResourceTests.java │ ├── StorageContentTypeResolverTests.java │ ├── StorageExceptionTests.java │ ├── StorageImplTests.java │ ├── StorageLocationTests.java │ └── StorageObjectMetadataTests.java ├── spring-cloud-oci-streaming ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── oracle │ │ └── cloud │ │ └── spring │ │ └── streaming │ │ ├── Streaming.java │ │ └── StreamingImpl.java │ └── test │ └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── streaming │ └── StreamingImplTests.java └── spring-cloud-oci-vault ├── pom.xml └── src ├── main └── java │ └── com │ └── oracle │ └── cloud │ └── spring │ └── vault │ ├── VaultTemplate.java │ └── VaultTemplateImpl.java └── test └── java └── com └── oracle └── cloud └── spring └── vault └── VaultTemplateImplTest.java /.github/workflows/integrationTest.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # Integration tests for github are disabled temporarily 3 | 4 | name: Run the Integration Tests for Spring Cloud Oracle 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-22.04 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Setup Java 17 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 17 21 | distribution: 'temurin' 22 | java-package: 'jdk' 23 | cache: 'maven' 24 | - name: Run Maven Build and Test 25 | working-directory: ./spring-cloud-oci 26 | run: | 27 | mvn clean \ 28 | -Pspring-cloud-oci-ci-it \ 29 | -DuserId=${{ secrets.userId }} \ 30 | -DtenantId=${{ secrets.tenantId }} \ 31 | -Dfingerprint=${{ secrets.fingerprint }} \ 32 | -Dregion=${{ vars.region }} \ 33 | -DprivateKeyContent=${{ secrets.privateKeyContent }} \ 34 | -Dit.notification=${{ vars.it_notification }} \ 35 | -DtopicName=${{ vars.topicName }} \ 36 | -DcompartmentId=${{ secrets.compartmentId }} \ 37 | -Dit.logging=${{ vars.it_logging }} \ 38 | -DlogId=${{ vars.logId }} \ 39 | -Dit.storage=${{ vars.it_storage }} \ 40 | -DbucketName=${{ vars.bucketName }} \ 41 | install -DskipTests 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, 2024, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | .DS_Store 5 | **/*.rpm 6 | **/*.jar 7 | **/*.bin 8 | pom.xml.versionsBackup 9 | .mvn/ 10 | 11 | ### STS ### 12 | .apt_generated 13 | .classpath 14 | .factorypath 15 | .project 16 | .settings 17 | .springBeans 18 | .sts4-cache 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | .idea/** 26 | 27 | ### NetBeans ### 28 | /nbproject/private/ 29 | /nbbuild/ 30 | /dist/ 31 | /nbdist/ 32 | /.nb-gradle/ 33 | build/ 34 | !**/src/main/**/build/ 35 | !**/src/test/**/build/ 36 | 37 | ### VS Code ### 38 | .vscode 39 | /.jpb/** 40 | 41 | *.log 42 | .run 43 | target/ 44 | Thumbs.db 45 | run-app.sh -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security vulnerabilities 2 | 3 | Oracle values the independent security research community and believes that 4 | responsible disclosure of security vulnerabilities helps us ensure the security 5 | and privacy of all our users. 6 | 7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you 8 | believe you have found a security vulnerability, please submit a report to 9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review 10 | some additional information on [how to report security vulnerabilities to Oracle][2]. 11 | We encourage people who contact Oracle Security to use email encryption using 12 | [our encryption key][3]. 13 | 14 | We ask that you do not use other channels or contact the project maintainers 15 | directly. 16 | 17 | Non-vulnerability related security issues including ideas for new or improved 18 | security features are welcome on GitHub Issues. 19 | 20 | ## Security updates, alerts and bulletins 21 | 22 | Security updates will be released on a regular cadence. Many of our projects 23 | will typically release security fixes in conjunction with the 24 | Oracle Critical Patch Update program. Additional 25 | information, including past advisories, is available on our [security alerts][4] 26 | page. 27 | 28 | ## Security-related information 29 | 30 | We will provide security related information such as a threat model, considerations 31 | for secure use, or any known security issues in our documentation. Please note 32 | that labs and sample code are intended to demonstrate a concept and may not be 33 | sufficiently hardened for production use. 34 | 35 | [1]: mailto:secalert_us@oracle.com 36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html 37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html 38 | [4]: https://www.oracle.com/security-alerts/ 39 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | 35 | *.jar 36 | .metadata/ 37 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/samples/DemoTests.java: -------------------------------------------------------------------------------- 1 | package com.oracle.stream; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | 5 | public class DemoTests { 6 | int y = 0; 7 | public static void main(String[] args) { 8 | SpringApplication.run(DemoTests.class, 9 | "--spring.datasource.url=jdbc:oracle:thin:@cdb1_pdb1_wallet", 10 | "--spring.datasource.oracleucp.connection-properties.oracle.net.wallet_location=C:/tmp/wallet", 11 | "--spring.datasource.oracleucp.connection-properties.oracle.net.tns_admin=C:/tmp/wallet", 12 | "--spring.datasource.driver-class-name=oracle.jdbc.OracleDriver", 13 | "--spring.datasource.type=oracle.ucp.jdbc.PoolDataSource", 14 | "--spring.datasource.oracleucp.connection-factory-class-name=oracle.jdbc.pool.OracleDataSource", 15 | "--spring.cloud.function.definition=consume;produce1", 16 | "--spring.cloud.stream.default.destination=AADI_TEST", 17 | "--spring.cloud.stream.default.group=t1", 18 | "--spring.cloud.stream.bindings.produce1-out-0.producer.requiredGroups=t1"); /**/ 19 | } 20 | 21 | 22 | @Bean 23 | public Consumer consume() { 24 | return to -> System.out.println("Received: " + to); 25 | } 26 | 27 | @Bean 28 | public Supplier produce1() { 29 | return () -> { 30 | System.out.println("Sending Message: "); 31 | return new TestObject(y++); 32 | }; 33 | } 34 | } 35 | 36 | class TestObject { 37 | private int x; 38 | 39 | TestObject(int x) { 40 | this.x = x; 41 | } 42 | 43 | TestObject() { 44 | 45 | } 46 | 47 | public int getX() { 48 | return this.x; 49 | } 50 | 51 | public void setX(int x) { 52 | this.x = x; 53 | } 54 | 55 | public String toString() { 56 | return "TestObject[x=" + this.x + "]"; 57 | } 58 | } -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/scripts/deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2024, Oracle and/or its affiliates. 3 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | 5 | set -euo pipefail 6 | 7 | usage() { 8 | echo "Usage: $0 -v version -u repository.url -r repository.name " 9 | exit 1 10 | } 11 | 12 | VERSION="" 13 | REPOSITORY_NAME="" 14 | REPOSITORY_URL="" 15 | 16 | if [ -z "$(command -v mvn)" ]; then 17 | echo "Error: 'mvn' binary not found on PATH. Install 'mvn' before running this script." 18 | fi 19 | 20 | while getopts ":v:r:u:" opt; do 21 | case $opt in 22 | v) VERSION="$OPTARG";; 23 | u) REPOSITORY_URL="$OPTARG";; 24 | r) REPOSITORY_NAME="$OPTARG";; 25 | \?) echo "Invalid option -$OPTARG" >&2; usage;; 26 | :) echo "Option -$OPTARG requires an argument." >&2; usage;; 27 | esac 28 | done 29 | 30 | if [ -z "$VERSION" ] || [ -z "$REPOSITORY_URL" ] || [ -z "$REPOSITORY_NAME" ]; then 31 | echo "Error: -v, -u, and -r options are required." 32 | usage 33 | fi 34 | 35 | echo "Setting project version = $VERSION" 36 | 37 | mvn -q versions:set -DnewVersion="$VERSION" 38 | 39 | echo "Successfully set project version = $VERSION" 40 | 41 | echo "Deploying project to ${REPOSITORY_URL}/${REPOSITORY_NAME}" 42 | 43 | mvn -q deploy -Drepository.url="$REPOSITORY_URL" -Drepository.name="$REPOSITORY_NAME" -DskipTests 44 | 45 | echo "Successfully deployed project to ${REPOSITORY_URL}/${REPOSITORY_NAME}" 46 | 47 | # shellcheck disable=SC2016 48 | PACKAGES="$(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q)" 49 | printf "The following artifacts have been created for upload:\n\n" 50 | for PACKAGE in $PACKAGES; do 51 | echo "com.oracle.database.spring.cloud-stream-binder:${PACKAGE}:${VERSION}" 52 | done 53 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/spring-cloud-stream-binder-txeventq-sample/src/main/java/com/oracle/database/spring/cloud/stream/binder/sample/StreamConfiguration.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.cloud.stream.binder.sample; 4 | 5 | import java.util.function.Consumer; 6 | import java.util.function.Function; 7 | 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Configuration 13 | public class StreamConfiguration { 14 | private @Value("${phrase}") String phrase; 15 | 16 | @Bean 17 | public Function toUpperCase() { 18 | return String::toUpperCase; 19 | } 20 | 21 | @Bean 22 | public Consumer stdoutConsumer() { 23 | return s -> System.out.println("Consumed: " + s); 24 | } 25 | 26 | @Bean 27 | public WordSupplier wordSupplier() { 28 | return new WordSupplier(phrase); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/spring-cloud-stream-binder-txeventq-sample/src/main/java/com/oracle/database/spring/cloud/stream/binder/sample/TxEventQSampleApp.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.cloud.stream.binder.sample; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | public class TxEventQSampleApp { 10 | public static void main(String[] args) { 11 | SpringApplication.run(TxEventQSampleApp.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/spring-cloud-stream-binder-txeventq-sample/src/main/java/com/oracle/database/spring/cloud/stream/binder/sample/WordSupplier.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.cloud.stream.binder.sample; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | import java.util.function.Supplier; 6 | 7 | public class WordSupplier implements Supplier { 8 | private final String[] words; 9 | private final AtomicInteger idx = new AtomicInteger(0); 10 | private final AtomicBoolean done = new AtomicBoolean(false); 11 | 12 | public WordSupplier(String phrase) { 13 | this.words = phrase.split(" "); 14 | } 15 | 16 | @Override 17 | public String get() { 18 | int i = idx.getAndAccumulate(words.length, (x, y) -> { 19 | if (x < words.length - 1) { 20 | return x + 1; 21 | } 22 | done.set(true); 23 | return 0; 24 | }); 25 | return words[i]; 26 | } 27 | 28 | public boolean done() { 29 | return done.get(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/spring-cloud-stream-binder-txeventq-sample/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | phrase: "Spring Cloud Stream simplifies event-driven microservices with powerful messaging capabilities." 2 | 3 | spring: 4 | cloud: 5 | stream: 6 | bindings: 7 | wordSupplier-out-0: 8 | destination: toUpperCase-in-0 9 | group: t1 10 | producer: 11 | required-groups: 12 | - t1 13 | stdoutConsumer-in-0: 14 | destination: toUpperCase-out-0 15 | group: t1 16 | function: 17 | definition: wordSupplier;toUpperCase;stdoutConsumer 18 | 19 | datasource: 20 | username: ${USERNAME} 21 | password: ${PASSWORD} 22 | url: ${JDBC_URL} 23 | driver-class-name: oracle.jdbc.OracleDriver 24 | type: oracle.ucp.jdbc.PoolDataSourceImpl 25 | oracleucp: 26 | initial-pool-size: 1 27 | min-pool-size: 1 28 | max-pool-size: 30 29 | connection-pool-name: TxEventQSample 30 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 31 | server: 32 | port: 9001 33 | 34 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/spring-cloud-stream-binder-txeventq-sample/src/test/resources/init.sql: -------------------------------------------------------------------------------- 1 | alter session set container=freepdb1; 2 | grant unlimited tablespace to testuser; 3 | grant select_catalog_role to testuser; 4 | grant execute on dbms_aq to testuser; 5 | grant execute on dbms_aqadm to testuser; 6 | grant execute on dbms_aqin to testuser; 7 | grant execute on dbms_aqjms_internal to testuser; 8 | grant execute on dbms_teqk to testuser; 9 | grant execute on DBMS_RESOURCE_MANAGER to testuser; 10 | grant select on sys.aq$_queue_shards to testuser; 11 | grant select on user_queue_partition_assignment_table to testuser; 12 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/config/JmsBinderAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | ** 7 | */ 8 | 9 | /* 10 | * Licensed to the Apache Software Foundation (ASF) under one or more 11 | * contributor license agreements. See the NOTICE file distributed with 12 | * this work for additional information regarding copyright ownership. 13 | * The ASF licenses this file to You under the Apache License, Version 2.0 14 | * (the "License"); you may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | package com.oracle.database.spring.cloud.stream.binder.config; 27 | 28 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 29 | import org.springframework.cloud.stream.binder.Binder; 30 | import org.springframework.context.annotation.Configuration; 31 | import org.springframework.context.annotation.Import; 32 | 33 | @Configuration 34 | @ConditionalOnMissingBean(Binder.class) 35 | @Import({JmsBinderGlobalConfiguration.class}) 36 | public class JmsBinderAutoConfiguration { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/config/JmsProducerProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | package com.oracle.database.spring.cloud.stream.binder.config; 26 | 27 | public class JmsProducerProperties { 28 | private String serializer = null; 29 | 30 | public String getSerializer() { 31 | return this.serializer; 32 | } 33 | 34 | public void setSerializer(String serializer) { 35 | this.serializer = serializer; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/serialize/Deserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | package com.oracle.database.spring.cloud.stream.binder.serialize; 26 | 27 | public interface Deserializer { 28 | public T deserialize(byte[] bytes); 29 | } 30 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/serialize/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | package com.oracle.database.spring.cloud.stream.binder.serialize; 26 | 27 | public interface Serializer { 28 | public byte[] serialize(Object data); 29 | } 30 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/utils/AnonymousNamingStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | package com.oracle.database.spring.cloud.stream.binder.utils; 26 | 27 | public interface AnonymousNamingStrategy { 28 | 29 | String generateName(); 30 | 31 | String generateName(String prefix); 32 | } 33 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/utils/DestinationNameResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | package com.oracle.database.spring.cloud.stream.binder.utils; 26 | 27 | import org.springframework.util.StringUtils; 28 | 29 | public class DestinationNameResolver { 30 | private AnonymousNamingStrategy namingStrategy; 31 | 32 | public DestinationNameResolver(AnonymousNamingStrategy namingStrategy) { 33 | this.namingStrategy = namingStrategy; 34 | } 35 | 36 | public String resolveGroupName(String group) { 37 | boolean anonymous = !StringUtils.hasText(group); 38 | return anonymous ? namingStrategy.generateName() : group; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/utils/MessageRecoverer.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one or more 10 | * contributor license agreements. See the NOTICE file distributed with 11 | * this work for additional information regarding copyright ownership. 12 | * The ASF licenses this file to You under the Apache License, Version 2.0 13 | * (the "License"); you may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | package com.oracle.database.spring.cloud.stream.binder.utils; 26 | 27 | import jakarta.jms.Message; 28 | 29 | public interface MessageRecoverer { 30 | /** 31 | * Recover from the failure to deliver a message. 32 | * 33 | * @param undeliveredMessage the message that has not been delivered. 34 | * @param cause the reason for the failure to deliver. 35 | */ 36 | void recover(Message undeliveredMessage, String dlq, Throwable cause); 37 | } 38 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/utils/TxEventQBinderHeaderConstants.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.cloud.stream.binder.utils; 2 | 3 | public class TxEventQBinderHeaderConstants { 4 | public static final String MESSAGE_CONNECTION = "oracle.jdbc.internal.connection"; 5 | public static final String CONNECTION_CONSUMER = "oracle.jdbc.internal.callback"; 6 | public static final String MESSAGE_CONTEXT = "oracle.jdbc.internal.message_context"; 7 | 8 | private TxEventQBinderHeaderConstants() { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/java/com/oracle/database/spring/cloud/stream/binder/utils/TxEventQUtils.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.cloud.stream.binder.utils; 2 | 3 | import java.sql.Connection; 4 | import java.util.function.Consumer; 5 | 6 | import org.springframework.messaging.Message; 7 | 8 | public class TxEventQUtils { 9 | /* Private constructor to avoid creating object of class TxEventQUtils */ 10 | private TxEventQUtils() { 11 | } 12 | 13 | /* Static Utility Methods */ 14 | public static Connection getDBConnection(Message message) { 15 | return (Connection) message 16 | .getHeaders() 17 | .getOrDefault(TxEventQBinderHeaderConstants.MESSAGE_CONNECTION, null); 18 | } 19 | 20 | public static Message setConnectionCallbackContext(Message message, 21 | Consumer callback, 22 | Message oldMessage) { 23 | return TxEventQMessageBuilder 24 | .fromMessage(message) 25 | .setConnectionCallbackContext(callback, oldMessage) 26 | .build(); 27 | } 28 | 29 | public static Message setConnectionCallback(Message message, Consumer callback) { 30 | return TxEventQMessageBuilder 31 | .fromMessage(message) 32 | .setConnectionCallback(callback) 33 | .build(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/main/resources/META-INF/spring.binders: -------------------------------------------------------------------------------- 1 | txeventqjms=\ 2 | com.oracle.database.spring.cloud.stream.binder.config.TxEventQJmsConfiguration 3 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/test/java/com/oracle/database/spring/cloud/stream/binder/TEQSpringBootIT.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.cloud.stream.binder; 2 | 3 | import java.sql.SQLException; 4 | 5 | import com.oracle.database.spring.cloud.stream.binder.config.TxEventQJmsConfiguration; 6 | import oracle.ucp.jdbc.PoolDataSource; 7 | import oracle.ucp.jdbc.PoolDataSourceFactory; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.springframework.context.annotation.Import; 15 | import org.testcontainers.junit.jupiter.Container; 16 | import org.testcontainers.junit.jupiter.Testcontainers; 17 | import org.testcontainers.oracle.OracleContainer; 18 | 19 | @Testcontainers 20 | @SpringBootTest(classes = TxEventQJmsConfiguration.class) 21 | @Import(TEQSpringBootIT.Config.class) 22 | public class TEQSpringBootIT { 23 | @Container 24 | private static final OracleContainer oracleContainer = Util.oracleContainer(); 25 | 26 | @Configuration 27 | public static class Config { 28 | @Bean 29 | public PoolDataSource poolDataSource() throws SQLException { 30 | PoolDataSource poolDataSource = PoolDataSourceFactory.getPoolDataSource(); 31 | Util.configurePoolDataSource(poolDataSource, oracleContainer); 32 | return poolDataSource; 33 | } 34 | } 35 | 36 | @BeforeAll 37 | public static void setUp() throws Exception { 38 | Util.startOracleContainer(oracleContainer); 39 | } 40 | 41 | @Autowired 42 | JMSMessageChannelBinder jmsMessageChannelBinder; 43 | 44 | @Test 45 | void contextLoads() {} 46 | } 47 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/test/java/com/oracle/database/spring/cloud/stream/binder/Util.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.cloud.stream.binder; 2 | 3 | import java.io.IOException; 4 | import java.sql.SQLException; 5 | import java.time.Duration; 6 | import java.util.UUID; 7 | 8 | import oracle.ucp.jdbc.PoolDataSource; 9 | import org.testcontainers.oracle.OracleContainer; 10 | import org.testcontainers.utility.MountableFile; 11 | 12 | public class Util { 13 | public static OracleContainer oracleContainer() { 14 | return new OracleContainer("gvenzl/oracle-free:23.7-slim-faststart") 15 | .withStartupTimeout(Duration.ofMinutes(2)) // Needed for M1 Mac 16 | .withUsername("testuser") 17 | .withPassword("testpwd"); 18 | } 19 | 20 | public static void startOracleContainer(OracleContainer oracleContainer) throws IOException, InterruptedException { 21 | oracleContainer.start(); 22 | oracleContainer.copyFileToContainer(MountableFile.forClasspathResource("init.sql"), "/tmp/init.sql"); 23 | oracleContainer.execInContainer("sqlplus", "sys / as sysdba", "@/tmp/init.sql"); 24 | } 25 | 26 | public static void configurePoolDataSource(PoolDataSource ds, OracleContainer oracleContainer) throws SQLException { 27 | ds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); 28 | ds.setConnectionPoolName(UUID.randomUUID().toString()); 29 | ds.setURL(oracleContainer.getJdbcUrl()); 30 | ds.setUser(oracleContainer.getUsername()); 31 | ds.setPassword(oracleContainer.getPassword()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/test/java/nativetests/TestObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | 9 | /* 10 | * Licensed to the Apache Software Foundation (ASF) under one or more 11 | * contributor license agreements. See the NOTICE file distributed with 12 | * this work for additional information regarding copyright ownership. 13 | * The ASF licenses this file to You under the Apache License, Version 2.0 14 | * (the "License"); you may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | package nativetests; 27 | 28 | public class TestObject { 29 | private int x; 30 | 31 | public TestObject(int x) { 32 | this.x = x; 33 | } 34 | 35 | public TestObject() { 36 | 37 | } 38 | 39 | public int getX() { 40 | return this.x; 41 | } 42 | 43 | public void setX(int x) { 44 | this.x = x; 45 | } 46 | 47 | public String toString() { 48 | return "MyTestObject[x='" + this.x + "']"; 49 | } 50 | } -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/test/java/nativetests/TestObjectDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | 9 | /* 10 | * Licensed to the Apache Software Foundation (ASF) under one or more 11 | * contributor license agreements. See the NOTICE file distributed with 12 | * this work for additional information regarding copyright ownership. 13 | * The ASF licenses this file to You under the Apache License, Version 2.0 14 | * (the "License"); you may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | package nativetests; 27 | 28 | import com.oracle.database.spring.cloud.stream.binder.serialize.Deserializer; 29 | 30 | public class TestObjectDeserializer implements Deserializer { 31 | 32 | @Override 33 | public TestObject deserialize(byte[] bytes) { 34 | String s = new String(bytes); 35 | int x = Integer.valueOf(s.substring(16, s.length() - 2)); 36 | return new TestObject(x); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/test/java/nativetests/TestObjectSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** TxEventQ Support for Spring Cloud Stream 3 | ** Copyright (c) 2023, 2024 Oracle and/or its affiliates. 4 | ** 5 | ** This file has been modified by Oracle Corporation. 6 | */ 7 | 8 | 9 | /* 10 | * Licensed to the Apache Software Foundation (ASF) under one or more 11 | * contributor license agreements. See the NOTICE file distributed with 12 | * this work for additional information regarding copyright ownership. 13 | * The ASF licenses this file to You under the Apache License, Version 2.0 14 | * (the "License"); you may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | package nativetests; 27 | 28 | import com.oracle.database.spring.cloud.stream.binder.serialize.Serializer; 29 | 30 | public class TestObjectSerializer implements Serializer { 31 | 32 | @Override 33 | public byte[] serialize(Object data) { 34 | if (data instanceof TestObject) { 35 | return data.toString().getBytes(); 36 | } 37 | throw new RuntimeException("Only payloads of type TestObject are supported"); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /database/spring-cloud-stream-binder-oracle-txeventq/src/test/resources/init.sql: -------------------------------------------------------------------------------- 1 | alter session set container=freepdb1; 2 | grant unlimited tablespace to testuser; 3 | grant select_catalog_role to testuser; 4 | grant execute on dbms_aq to testuser; 5 | grant execute on dbms_aqadm to testuser; 6 | grant execute on dbms_aqin to testuser; 7 | grant execute on dbms_aqjms_internal to testuser; 8 | grant execute on dbms_teqk to testuser; 9 | grant execute on DBMS_RESOURCE_MANAGER to testuser; 10 | grant select on sys.aq$_queue_shards to testuser; 11 | grant select on user_queue_partition_assignment_table to testuser; 12 | -------------------------------------------------------------------------------- /database/starters/Makefile: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- 2 | # Copyright (c) 2025, Oracle and/or its affiliates. 3 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | # ---------------------------------------------------------------------------- 5 | 6 | .PHONY: clean build docs javadocs 7 | 8 | mvncmd=mvnd 9 | 10 | ifeq (, $(shell which ${mvncmd})) 11 | mvncmd=mvn 12 | endif 13 | 14 | 15 | build: 16 | ${mvncmd} verify 17 | 18 | clean: 19 | ${mvncmd} clean 20 | 21 | docs: 22 | ${mvncmd} verify -Pasciidocs -DskipTests=true 23 | 24 | javadocs: 25 | ${mvncmd} clean package javadoc:aggregate -DskipTests=true -e 26 | -------------------------------------------------------------------------------- /database/starters/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Database Spring Starters 2 | 3 | Oracle Database Spring Starters implements Spring Boot Starters to facilitate the use of Oracle Database with Spring Boot. 4 | 5 | The following starters are provided: 6 | 7 | | Starter | Description | 8 | |------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------| 9 | | [Oracle Spring Boot Starter UCP](oracle-spring-boot-starter-ucp) | Autoconfigure UCP for Oracle Database, over the default Hikari Connection Pool. | 10 | | [Oracle Spring Boot Starter AQJMS](oracle-spring-boot-starter-aqjms) | Autoconfigure Oracle Database AQJMS Connections. | 11 | | [Oracle Spring Boot Starter Wallet](oracle-spring-boot-starter-wallet) | Bundle dependencies for Oracle Wallet. | 12 | | [Oracle Spring Boot Starter JSON Collections](oracle-spring-boot-starter-json-collections) | Autoconfiguration and utilities for JSON with Oracle Database | 13 | | [Oracle Spring Boot Starter for the Kafka Java Client for Oracle Database Transactional Event Queues](oracle-spring-boot-starter-okafka) | Autoconfiguration for Kafka Java Client for Oracle Transactional Event Queues | 14 | 15 | 16 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/java/com/oracle/spring/json/JsonCollectionsAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json; 4 | 5 | import com.oracle.spring.json.jsonb.JSONB; 6 | import com.oracle.spring.json.kafka.OSONKafkaSerializationFactory; 7 | import jakarta.json.bind.JsonbBuilder; 8 | import oracle.sql.json.OracleJsonFactory; 9 | import org.apache.kafka.common.serialization.Deserializer; 10 | import org.apache.kafka.common.serialization.Serializer; 11 | import org.eclipse.yasson.YassonJsonb; 12 | import org.springframework.boot.autoconfigure.AutoConfiguration; 13 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 14 | import org.springframework.context.annotation.Bean; 15 | 16 | @AutoConfiguration 17 | public class JsonCollectionsAutoConfiguration { 18 | @Bean 19 | @ConditionalOnClass(OracleJsonFactory.class) 20 | OracleJsonFactory oracleJsonFactory() { 21 | return new OracleJsonFactory(); 22 | } 23 | 24 | @Bean 25 | @ConditionalOnClass(YassonJsonb.class) 26 | YassonJsonb yassonJsonb() { 27 | return (YassonJsonb) JsonbBuilder.create(); 28 | } 29 | 30 | @Bean 31 | @ConditionalOnClass({OracleJsonFactory.class, YassonJsonb.class}) 32 | public JSONB jsonb(OracleJsonFactory oracleJsonFactory, YassonJsonb yassonJsonb) { 33 | return new JSONB(oracleJsonFactory, yassonJsonb); 34 | } 35 | 36 | @Bean 37 | @ConditionalOnClass(value = { 38 | Deserializer.class, 39 | Serializer.class 40 | }) 41 | public OSONKafkaSerializationFactory osonSerializationFactory(JSONB jsonb) { 42 | return new OSONKafkaSerializationFactory(jsonb); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/java/com/oracle/spring/json/jsonb/JSONBRowMapper.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.jsonb; 4 | 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | 8 | import jakarta.json.stream.JsonParser; 9 | import org.springframework.jdbc.core.RowMapper; 10 | 11 | public class JSONBRowMapper implements RowMapper { 12 | private final JSONB mapper; 13 | private final Class clazz; 14 | private final int osonRowNumber; 15 | 16 | public JSONBRowMapper(JSONB mapper, Class clazz, int osonRowNumber) { 17 | this.mapper = mapper; 18 | this.clazz = clazz; 19 | this.osonRowNumber = osonRowNumber; 20 | } 21 | 22 | public JSONBRowMapper(JSONB mapper, Class clazz) { 23 | this(mapper, clazz, 1); 24 | } 25 | 26 | @Override 27 | public T mapRow(ResultSet rs, int rowNum) throws SQLException { 28 | JsonParser parser = rs.getObject(osonRowNumber, JsonParser.class); 29 | return mapper.fromOSON(parser, clazz); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/java/com/oracle/spring/json/kafka/OSONDeserializer.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.kafka; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | import com.oracle.spring.json.jsonb.JSONB; 8 | import org.apache.kafka.common.serialization.Deserializer; 9 | 10 | /** 11 | * The OSONDeserializer converts JSONB byte arrays to java objects. 12 | * @param deserialization type 13 | */ 14 | public class OSONDeserializer implements Deserializer { 15 | private final JSONB jsonb; 16 | private final Class clazz; 17 | 18 | public OSONDeserializer(JSONB jsonb, Class clazz) { 19 | this.jsonb = jsonb; 20 | this.clazz = clazz; 21 | } 22 | 23 | @Override 24 | public T deserialize(String s, byte[] bytes) { 25 | return jsonb.fromOSON(ByteBuffer.wrap(bytes), clazz); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/java/com/oracle/spring/json/kafka/OSONKafkaSerializationFactory.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.kafka; 4 | 5 | import com.oracle.spring.json.jsonb.JSONB; 6 | 7 | public class OSONKafkaSerializationFactory { 8 | private final JSONB jsonb; 9 | 10 | public OSONKafkaSerializationFactory(JSONB jsonb) { 11 | this.jsonb = jsonb; 12 | } 13 | 14 | public OSONDeserializer createDeserializer(Class clazz) { 15 | return new OSONDeserializer<>(jsonb, clazz); 16 | } 17 | 18 | public OSONSerializer createSerializer() { 19 | return new OSONSerializer<>(jsonb); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/java/com/oracle/spring/json/kafka/OSONSerializer.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.kafka; 4 | 5 | import com.oracle.spring.json.jsonb.JSONB; 6 | import org.apache.kafka.common.serialization.Serializer; 7 | 8 | /** 9 | * The OSONSerializer converts java objects to a JSONB byte array. 10 | * @param serialization type. 11 | */ 12 | public class OSONSerializer implements Serializer { 13 | private final JSONB jsonb; 14 | 15 | public OSONSerializer(JSONB jsonb) { 16 | this.jsonb = jsonb; 17 | } 18 | 19 | @Override 20 | public byte[] serialize(String s, T obj) { 21 | return jsonb.toOSON(obj); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.oracle.spring.json.JsonCollectionsAutoConfiguration -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.oracle.spring.json.JsonCollectionsAutoConfiguration -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/test/java/com/oracle/spring/json/test/Student.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.test; 4 | 5 | import java.util.UUID; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class Student { 15 | String id; 16 | String name; 17 | StudentDetails details; 18 | 19 | public static String newId() { 20 | return UUID.randomUUID().toString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-data-tools/src/test/java/com/oracle/spring/json/test/StudentDetails.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.test; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class StudentDetails { 13 | String major; 14 | double gpa; 15 | double credits; 16 | } 17 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/main/java/com/oracle/spring/json/duality/annotation/AccessMode.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.annotation; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Target({}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface AccessMode { 13 | boolean insert() default false; 14 | boolean update() default false; 15 | boolean delete() default false; 16 | } 17 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/main/java/com/oracle/spring/json/duality/annotation/JsonRelationalDualityView.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.annotation; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | @Documented 13 | @Target({ElementType.TYPE, ElementType.FIELD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface JsonRelationalDualityView { 16 | String name() default ""; 17 | 18 | boolean selfReferential() default false; 19 | 20 | AccessMode accessMode() default @AccessMode(); 21 | } 22 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/main/java/com/oracle/spring/json/duality/annotation/JsonRelationalDualityViewScan.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.annotation; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | 13 | @Documented 14 | @Target({ElementType.TYPE}) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface JsonRelationalDualityViewScan { 17 | String[] basePackages() default {}; 18 | 19 | Class[] basePackageClasses() default {}; 20 | } 21 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/main/java/com/oracle/spring/json/duality/builder/RootSnippet.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.builder; 5 | 6 | public enum RootSnippet { 7 | NONE(null), 8 | VALIDATE(null), 9 | CREATE("create force editionable json relational duality view"), 10 | CREATE_DROP(CREATE.snippet), 11 | UPDATE("create or replace force editionable json relational duality view"); 12 | private final String snippet; 13 | 14 | RootSnippet(String snippet) { 15 | this.snippet = snippet; 16 | } 17 | 18 | public String getSnippet() { 19 | return snippet; 20 | } 21 | 22 | public static RootSnippet fromDdlAuto(String ddlAuto) { 23 | if (ddlAuto == null) { 24 | return NONE; 25 | } 26 | // none, validate, update, create, and create-drop 27 | return switch (ddlAuto) { 28 | case "none" -> NONE; 29 | case "validate" -> VALIDATE; 30 | case "create" -> CREATE; 31 | case "create-drop" -> CREATE_DROP; 32 | case "update" -> UPDATE; 33 | default -> throw new IllegalStateException("Unexpected value: " + ddlAuto); 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/main/java/com/oracle/spring/json/duality/builder/ScannerConfiguration.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.builder; 5 | 6 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityView; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.core.io.ResourceLoader; 12 | import org.springframework.data.util.AnnotatedTypeScanner; 13 | 14 | @Configuration 15 | public class ScannerConfiguration { 16 | @Bean 17 | @Qualifier("jsonRelationalDualityViewScanner") 18 | public AnnotatedTypeScanner scanner(ResourceLoader resourceLoader, Environment environment) { 19 | AnnotatedTypeScanner dvScanner = new AnnotatedTypeScanner(JsonRelationalDualityView.class); 20 | 21 | dvScanner.setResourceLoader(resourceLoader); 22 | dvScanner.setEnvironment(environment); 23 | return dvScanner; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/Application.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality; 5 | 6 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityViewScan; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.autoconfigure.domain.EntityScan; 10 | 11 | @SpringBootApplication 12 | @EntityScan(basePackages = { 13 | "com.oracle.spring.json.duality.model" 14 | } 15 | ) 16 | @JsonRelationalDualityViewScan( 17 | basePackages = { 18 | "com.oracle.spring.json.duality.model" 19 | } 20 | ) 21 | public class Application { 22 | public static void main(String[] args) { 23 | SpringApplication.run(Application.class, args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/book/Book.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.duality.model.book; 4 | 5 | import java.util.Objects; 6 | 7 | import com.oracle.spring.json.duality.annotation.AccessMode; 8 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityView; 9 | import jakarta.json.bind.annotation.JsonbProperty; 10 | import jakarta.persistence.Column; 11 | import jakarta.persistence.Entity; 12 | import jakarta.persistence.GeneratedValue; 13 | import jakarta.persistence.GenerationType; 14 | import jakarta.persistence.Id; 15 | import jakarta.persistence.Table; 16 | import lombok.Getter; 17 | import lombok.Setter; 18 | 19 | import static com.oracle.spring.json.duality.builder.Annotations._ID_FIELD; 20 | 21 | @Entity 22 | @Table(name = "books") 23 | @JsonRelationalDualityView(name = "book_dv", accessMode = @AccessMode( 24 | insert = true, 25 | update = true 26 | )) 27 | @Getter 28 | @Setter 29 | public class Book { 30 | 31 | @Id 32 | @JsonbProperty(_ID_FIELD) 33 | @GeneratedValue(strategy = GenerationType.IDENTITY) 34 | @Column(name = "book_id") 35 | private Long bookId; 36 | 37 | @Column(nullable = false) 38 | private String title; 39 | 40 | @Override 41 | public final boolean equals(Object o) { 42 | if (!(o instanceof Book book)) return false; 43 | 44 | return Objects.equals(bookId, book.bookId) && Objects.equals(title, book.title); 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | int result = Objects.hashCode(bookId); 50 | result = 31 * result + Objects.hashCode(title); 51 | return result; 52 | } 53 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/book/Member.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.duality.model.book; 4 | 5 | import java.util.List; 6 | 7 | import com.oracle.spring.json.duality.annotation.AccessMode; 8 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityView; 9 | import jakarta.json.bind.annotation.JsonbProperty; 10 | import jakarta.persistence.CascadeType; 11 | import jakarta.persistence.Column; 12 | import jakarta.persistence.Entity; 13 | import jakarta.persistence.GeneratedValue; 14 | import jakarta.persistence.GenerationType; 15 | import jakarta.persistence.Id; 16 | import jakarta.persistence.OneToMany; 17 | import jakarta.persistence.Table; 18 | import lombok.Getter; 19 | import lombok.Setter; 20 | 21 | import static com.oracle.spring.json.duality.builder.Annotations._ID_FIELD; 22 | 23 | @Entity 24 | @Table(name = "members") 25 | @JsonRelationalDualityView(accessMode = @AccessMode( 26 | insert = true, 27 | update = true, 28 | delete = true 29 | )) 30 | @Getter 31 | @Setter 32 | public class Member { 33 | 34 | @Id 35 | @GeneratedValue(strategy = GenerationType.IDENTITY) 36 | @JsonbProperty(_ID_FIELD) 37 | @Column(name = "member_id") 38 | private Long memberId; 39 | 40 | @Column(name = "name", nullable = false) 41 | private String fullName; 42 | 43 | @JsonRelationalDualityView(name = "loans", accessMode = @AccessMode( 44 | insert = true, 45 | update = true 46 | )) 47 | @OneToMany(mappedBy = "member", cascade = CascadeType.ALL) 48 | private List loans; 49 | } 50 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/employee/ManagerAdapter.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.duality.model.employee; 4 | 5 | import jakarta.json.bind.adapter.JsonbAdapter; 6 | 7 | public class ManagerAdapter implements JsonbAdapter { 8 | @Override 9 | public SimpleEmployee adaptToJson(Employee employee) throws Exception { 10 | SimpleEmployee simpleEmployee = new SimpleEmployee(); 11 | simpleEmployee.set_id(employee.getId()); 12 | simpleEmployee.setName(employee.getName()); 13 | return simpleEmployee; 14 | } 15 | 16 | @Override 17 | public Employee adaptFromJson(SimpleEmployee simpleEmployee) throws Exception { 18 | Employee employee = new Employee(); 19 | employee.setId(simpleEmployee.get_id()); 20 | employee.setName(simpleEmployee.getName()); 21 | return employee; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/employee/ReportsAdapter.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.duality.model.employee; 4 | 5 | import java.util.List; 6 | 7 | import jakarta.json.bind.adapter.JsonbAdapter; 8 | 9 | public class ReportsAdapter implements JsonbAdapter, List> { 10 | 11 | @Override 12 | public List adaptToJson(List employees) throws Exception { 13 | return employees.stream().map(e -> { 14 | SimpleEmployee simpleEmployee = new SimpleEmployee(); 15 | simpleEmployee.set_id(e.getId()); 16 | simpleEmployee.setName(e.getName()); 17 | return simpleEmployee; 18 | }).toList(); 19 | } 20 | 21 | @Override 22 | public List adaptFromJson(List simpleEmployees) throws Exception { 23 | return simpleEmployees.stream().map(s -> { 24 | Employee employee = new Employee(); 25 | employee.setId(s.get_id()); 26 | employee.setName(s.getName()); 27 | return employee; 28 | }).toList(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/employee/SimpleEmployee.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.json.duality.model.employee; 4 | 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | public class SimpleEmployee { 11 | private Long _id; 12 | private String name; 13 | } 14 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/movie/DirectorBio.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.model.movie; 5 | 6 | import java.util.Objects; 7 | 8 | import jakarta.json.bind.annotation.JsonbProperty; 9 | import jakarta.json.bind.annotation.JsonbTransient; 10 | import jakarta.persistence.Column; 11 | import jakarta.persistence.Entity; 12 | import jakarta.persistence.FetchType; 13 | import jakarta.persistence.Id; 14 | import jakarta.persistence.JoinColumn; 15 | import jakarta.persistence.MapsId; 16 | import jakarta.persistence.OneToOne; 17 | import jakarta.persistence.Table; 18 | import lombok.Getter; 19 | import lombok.Setter; 20 | 21 | import static com.oracle.spring.json.duality.builder.Annotations._ID_FIELD; 22 | 23 | @Entity 24 | @Table(name = "director_bio") 25 | @Getter 26 | @Setter 27 | public class DirectorBio { 28 | @JsonbProperty(_ID_FIELD) 29 | @Id 30 | @Column(name = "director_id") 31 | private String directorId; 32 | 33 | @OneToOne(fetch = FetchType.LAZY) 34 | // The primary key will be copied from the director entity 35 | @MapsId 36 | @JoinColumn(name = "director_id") 37 | @JsonbTransient 38 | private Director director; 39 | 40 | @Column(name = "biography", columnDefinition = "CLOB") 41 | private String biography; 42 | 43 | @Override 44 | public final boolean equals(Object o) { 45 | if (!(o instanceof DirectorBio directorBio)) return false; 46 | return Objects.equals(getDirectorId(), directorBio.getDirectorId()); 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | return Objects.hashCode(getDirectorId()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/products/Order.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.model.products; 5 | 6 | import com.oracle.spring.json.duality.annotation.AccessMode; 7 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityView; 8 | import jakarta.json.bind.annotation.JsonbProperty; 9 | import jakarta.persistence.Column; 10 | import jakarta.persistence.Table; 11 | import lombok.Getter; 12 | import lombok.Setter; 13 | 14 | import java.util.Date; 15 | import java.util.Objects; 16 | 17 | import static com.oracle.spring.json.duality.builder.Annotations._ID_FIELD; 18 | 19 | @Getter 20 | @Setter 21 | @JsonRelationalDualityView(accessMode = @AccessMode(insert = true)) 22 | @Table(name = "orders") 23 | public class Order { 24 | @JsonbProperty(_ID_FIELD) 25 | @Column(name = "order_id") 26 | private Long id; 27 | @JsonRelationalDualityView(name = "product") 28 | @Column(name = "products") 29 | private Product product; 30 | private Integer quantity; 31 | @Column(name = "order_date") 32 | private Date orderDate; 33 | 34 | @Override 35 | public final boolean equals(Object o) { 36 | if (!(o instanceof Order order)) return false; 37 | 38 | return Objects.equals(getId(), order.getId()) && Objects.equals(getQuantity(), order.getQuantity()) && Objects.equals(getOrderDate(), order.getOrderDate()); 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | int result = Objects.hashCode(getId()); 44 | result = 31 * result + Objects.hashCode(getQuantity()); 45 | result = 31 * result + Objects.hashCode(getOrderDate()); 46 | return result; 47 | } 48 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/products/Product.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.model.products; 5 | 6 | import java.util.Objects; 7 | 8 | import com.oracle.spring.json.duality.annotation.AccessMode; 9 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityView; 10 | import jakarta.json.bind.annotation.JsonbProperty; 11 | import jakarta.persistence.Column; 12 | import jakarta.persistence.Table; 13 | import lombok.Getter; 14 | import lombok.Setter; 15 | 16 | import static com.oracle.spring.json.duality.builder.Annotations._ID_FIELD; 17 | 18 | @Getter 19 | @Setter 20 | @Table(name = "products") 21 | @JsonRelationalDualityView( 22 | name = "product_dv", 23 | accessMode = @AccessMode(insert = true) 24 | ) 25 | public class Product { 26 | @JsonbProperty(_ID_FIELD) 27 | @Column(name = "product_id") 28 | private Long id; 29 | private String name; 30 | private Double price; 31 | 32 | @Override 33 | public final boolean equals(Object o) { 34 | if (!(o instanceof Product product)) return false; 35 | 36 | return Objects.equals(getId(), product.getId()) && Objects.equals(getName(), product.getName()) && Objects.equals(getPrice(), product.getPrice()); 37 | } 38 | 39 | @Override 40 | public int hashCode() { 41 | int result = Objects.hashCode(getId()); 42 | result = 31 * result + Objects.hashCode(getName()); 43 | result = 31 * result + Objects.hashCode(getPrice()); 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/java/com/oracle/spring/json/duality/model/student/Student.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.json.duality.model.student; 5 | 6 | import com.oracle.spring.json.duality.annotation.JsonRelationalDualityView; 7 | import com.oracle.spring.json.duality.annotation.AccessMode; 8 | import jakarta.json.bind.annotation.JsonbProperty; 9 | import jakarta.persistence.Column; 10 | import jakarta.persistence.Entity; 11 | import jakarta.persistence.GeneratedValue; 12 | import jakarta.persistence.GenerationType; 13 | import jakarta.persistence.Id; 14 | import jakarta.persistence.Table; 15 | import lombok.EqualsAndHashCode; 16 | import lombok.Getter; 17 | import lombok.Setter; 18 | 19 | import static com.oracle.spring.json.duality.builder.Annotations._ID_FIELD; 20 | 21 | @Entity 22 | @Table(name = "STUDENT") 23 | @JsonRelationalDualityView( 24 | accessMode = @AccessMode( 25 | insert = true, 26 | update = true, 27 | delete = true 28 | ) 29 | ) 30 | @EqualsAndHashCode 31 | @Getter 32 | @Setter 33 | public class Student { 34 | @JsonbProperty(_ID_FIELD) 35 | @Id 36 | @GeneratedValue(strategy = GenerationType.UUID) 37 | private String id; 38 | @Column(name = "first_name") 39 | private String firstName; 40 | @Column(name = "last_name") 41 | private String lastName; 42 | private String email; 43 | private String major; 44 | private double credits; 45 | private double gpa; 46 | 47 | public Student() {} 48 | } 49 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: ${DB_URL} 4 | username: ${DB_USERNAME} 5 | password: ${DB_PASSWORD} 6 | driver-class-name: oracle.jdbc.OracleDriver 7 | type: oracle.ucp.jdbc.PoolDataSource 8 | oracleucp: 9 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 10 | connection-pool-name: ConsumerConnectionPool 11 | initial-pool-size: 15 12 | min-pool-size: 10 13 | max-pool-size: 30 14 | jpa: 15 | hibernate: 16 | ddl-auto: create-drop 17 | show-sql: true 18 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/products.sql: -------------------------------------------------------------------------------- 1 | create table products ( 2 | product_id number generated always as identity primary key, 3 | name varchar2(255) not null, 4 | price number(10,2) not null 5 | ); 6 | 7 | create table orders ( 8 | order_id number generated always as identity primary key, 9 | product_id number not null, 10 | quantity number not null, 11 | order_date date default sysdate, 12 | constraint fk_orders_product foreign key (product_id) references products(product_id) on delete cascade 13 | ); 14 | 15 | 16 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/views/actor-create.sql: -------------------------------------------------------------------------------- 1 | create force editionable json relational duality view actor_dv as actor @insert { 2 | _id : actor_id 3 | firstName : first_name 4 | lastName : last_name 5 | movies : movie_actor @insert [ { 6 | movie @unnest @insert { 7 | _id : movie_id 8 | title 9 | releaseYear : release_year 10 | genre 11 | } 12 | } ] 13 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/views/employee-create.sql: -------------------------------------------------------------------------------- 1 | create force editionable json relational duality view employee_dv as employee @insert @update @delete { 2 | _id : id 3 | name 4 | manager : employee @insert @update @link (from : [manager_id]) { 5 | _id : id 6 | name 7 | } 8 | reports : employee @insert @update { 9 | _id : id 10 | name 11 | } 12 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/views/member-create-drop.sql: -------------------------------------------------------------------------------- 1 | create force editionable json relational duality view members_dv as members @insert @update @delete { 2 | _id : member_id 3 | fullName : name 4 | loans @insert @update { 5 | _id : loan_id 6 | book : books @insert @update @link (from : [book_id]) { 7 | _id : book_id 8 | title 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/views/order-create.sql: -------------------------------------------------------------------------------- 1 | create force editionable json relational duality view orders_dv as orders @insert { 2 | _id : order_id 3 | quantity 4 | orderDate : order_date 5 | product : products { 6 | _id : product_id 7 | name 8 | price 9 | } 10 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/views/student-create.sql: -------------------------------------------------------------------------------- 1 | create force editionable json relational duality view student_dv as student @insert @update @delete { 2 | _id : id 3 | firstName : first_name 4 | lastName : last_name 5 | email 6 | major 7 | credits 8 | gpa 9 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-json-relational-duality-views/src/test/resources/views/student-update.sql: -------------------------------------------------------------------------------- 1 | create or replace force editionable json relational duality view student_dv as student @insert @update @delete { 2 | _id : id 3 | firstName : first_name 4 | lastName : last_name 5 | email 6 | major 7 | credits 8 | gpa 9 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-aqjms/src/main/java/com/oracle/spring/aqjms/AqJmsAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | 4 | package com.oracle.spring.aqjms; 5 | 6 | import javax.sql.DataSource; 7 | 8 | import com.oracle.spring.ucp.UCPAutoConfiguration; 9 | import jakarta.jms.ConnectionFactory; 10 | 11 | import org.springframework.boot.autoconfigure.AutoConfiguration; 12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 13 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 14 | import org.springframework.context.annotation.Bean; 15 | 16 | import oracle.jakarta.jms.AQjmsFactory; 17 | 18 | /** 19 | * This class autowires the configuration and injects both a JDBC DataSource 20 | * and a JMSConnectionFactory into your application. 21 | */ 22 | @AutoConfiguration 23 | @ConditionalOnClass({UCPAutoConfiguration.class}) 24 | public class AqJmsAutoConfiguration { 25 | @Bean 26 | @ConditionalOnMissingBean 27 | public ConnectionFactory aqJmsConnectionFactory(DataSource ds) { 28 | ConnectionFactory connectionFactory = null; 29 | try { 30 | connectionFactory = AQjmsFactory.getConnectionFactory(ds); 31 | } catch (Exception ignore) {} 32 | return connectionFactory; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-aqjms/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.oracle.spring.aqjms.AqJmsAutoConfiguration -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-aqjms/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.oracle.spring.aqjms.AqJmsAutoConfiguration -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-aqjms/src/test/java/com/oracle/spring/aqjms/AqJmsAutoConfigurationTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.aqjms; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import com.oracle.spring.ucp.UCPAutoConfiguration; 8 | import jakarta.jms.ConnectionFactory; 9 | import oracle.ucp.jdbc.PoolDataSourceImpl; 10 | import org.junit.jupiter.api.Assertions; 11 | import org.junit.jupiter.api.Test; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.context.annotation.Import; 15 | import org.springframework.test.context.TestPropertySource; 16 | 17 | import static org.assertj.core.api.Assertions.assertThat; 18 | 19 | @SpringBootTest(classes = {AqJmsAutoConfiguration.class, UCPAutoConfiguration.class}) 20 | @Import(Config.class) 21 | public class AqJmsAutoConfigurationTest { 22 | @Autowired 23 | DataSource dataSource; 24 | 25 | @Autowired 26 | ConnectionFactory connectionFactory; 27 | 28 | @Test 29 | void dataSourceConfigured() { 30 | assertThat(dataSource).isNotNull(); 31 | if (dataSource instanceof PoolDataSourceImpl ds) { 32 | assertThat(ds.getInitialPoolSize()).isEqualTo(15); 33 | assertThat(ds.getConnectionFactoryClassName()).isEqualTo("oracle.jdbc.pool.OracleDataSource"); 34 | assertThat(ds.getConnectionPoolName()).isEqualTo("SpringConnectionPool"); 35 | } else { 36 | Assertions.fail("Datasource is not a PoolDataSourceImpl: " + dataSource.getClass().getName()); 37 | } 38 | } 39 | 40 | @Test 41 | void aqjmsFactoryConfigured() { 42 | assertThat(connectionFactory).isNotNull(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-aqjms/src/test/java/com/oracle/spring/aqjms/Config.java: -------------------------------------------------------------------------------- 1 | package com.oracle.spring.aqjms; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import oracle.ucp.jdbc.PoolDataSourceFactory; 6 | import org.springframework.boot.test.context.TestConfiguration; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @TestConfiguration 10 | public class Config { 11 | @Bean 12 | DataSource dataSource() { 13 | return PoolDataSourceFactory.getPoolDataSource(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/README.md: -------------------------------------------------------------------------------- 1 | # Oracle Spring Boot Sample for JSON Relational Duality Views 2 | 3 | This sample application demonstrates how to use the Oracle Spring Boot Starter JSON Collections with [JSON Relational Duality Views](https://docs.oracle.com/en/database/oracle/oracle-database/23/jsnvu/overview-json-relational-duality-views.html) 4 | 5 | The Oracle Spring Boot Sample for JSON Relational Duality Views package includes the following components to demonstrate development with JSON Relational Duality Views from a Spring Boot Java context: 6 | 7 | - Entities for JSON Relational Duality Views (Student, Enrollment, Course, Lecture Hall) 8 | - Services to interact with the JSON Relational Duality Views 9 | - A SQL script that initializes the database, including the JSON Relational Duality Views. 10 | - A comprehensive test that uses Spring Boot services to manipulate data from JSON Relational Duality Views. 11 | 12 | ## Run the sample application 13 | 14 | The sample application test uses Testcontainers, and creates a temporary Oracle Free container database, and requires a docker runtime environment. 15 | 16 | To run the test application, run the following command: 17 | 18 | ```shell 19 | mvn test -Dtest=JSONDualitySampleApplicationTest 20 | ``` 21 | 22 | ## Configure your project to use Oracle JSON Relational Duality Views 23 | 24 | To use Oracle JSON Relational Duality Views from your Spring Boot application, add the following Maven dependency to your project: 25 | 26 | ```xml 27 | 28 | com.oracle.database.spring 29 | oracle-spring-boot-starter-json-collections 30 | 31 | ``` 32 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/CourseService.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonduality; 4 | 5 | import java.sql.PreparedStatement; 6 | import java.util.List; 7 | 8 | import com.oracle.spring.json.jsonb.JSONB; 9 | import com.oracle.spring.json.jsonb.JSONBRowMapper; 10 | import org.springframework.jdbc.core.JdbcTemplate; 11 | import org.springframework.jdbc.core.RowMapper; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | public class CourseService { 16 | private static final String byName = """ 17 | select * from courses_dv v 18 | where v.data.name = ? 19 | """; 20 | 21 | private final JdbcTemplate jdbcTemplate; 22 | private final JSONB jsonb; 23 | private final RowMapper rowMapper; 24 | 25 | public CourseService(JdbcTemplate jdbcTemplate, JSONB jsonb) { 26 | this.jdbcTemplate = jdbcTemplate; 27 | this.jsonb = jsonb; 28 | rowMapper = new JSONBRowMapper<>(jsonb, Course.class); 29 | } 30 | 31 | public List getCourseByName(String name) { 32 | return jdbcTemplate.query(con -> { 33 | PreparedStatement ps = con.prepareStatement(byName); 34 | ps.setString(1, name); 35 | return ps; 36 | }, rowMapper); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Enrollment.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonduality; 4 | 5 | public class Enrollment { 6 | private String _id; 7 | private Course course; 8 | 9 | public Enrollment() {} 10 | 11 | public Enrollment(String _id, Course course) { 12 | this._id = _id; 13 | this.course = course; 14 | } 15 | 16 | public String get_id() { 17 | return _id; 18 | } 19 | 20 | public void set_id(String _id) { 21 | this._id = _id; 22 | } 23 | 24 | public Course getCourse() { 25 | return course; 26 | } 27 | 28 | public void setCourse(Course course) { 29 | this.course = course; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "Enrollment{" + 35 | "_id='" + _id + '\'' + 36 | ", course=" + course + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonduality; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @SpringBootApplication 10 | public class JSONDualitySampleApplication { 11 | public static void main(String[] args) { 12 | SpringApplication.run(JSONDualitySampleApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/LectureHall.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonduality; 4 | 5 | public class LectureHall { 6 | private String _id; 7 | private String name; 8 | 9 | public LectureHall() {} 10 | 11 | public LectureHall(String _id, String name) { 12 | this._id = _id; 13 | this.name = name; 14 | } 15 | 16 | public String get_id() { 17 | return _id; 18 | } 19 | 20 | public void set_id(String _id) { 21 | this._id = _id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "LectureHall{" + 35 | "_id='" + _id + '\'' + 36 | ", name='" + name + '\'' + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | jpa: 3 | hibernate: 4 | ddl-auto: none 5 | datasource: 6 | username: ${USERNAME} 7 | password: ${PASSWORD} 8 | url: ${JDBC_URL} 9 | 10 | # Set these to use UCP over Hikari. 11 | driver-class-name: oracle.jdbc.OracleDriver 12 | type: oracle.ucp.jdbc.PoolDataSourceImpl 13 | oracleucp: 14 | initial-pool-size: 1 15 | min-pool-size: 1 16 | max-pool-size: 30 17 | connection-pool-name: UCPSampleApplication 18 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 19 | server: 20 | port: 9001 21 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/JSONEventsSampleApp.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | public class JSONEventsSampleApp { 10 | public static void main(String[] args) { 11 | SpringApplication.run(JSONEventsSampleApp.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/SensorController.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents; 4 | 5 | import java.util.List; 6 | 7 | import com.oracle.database.spring.jsonevents.model.Sensor; 8 | import com.oracle.database.spring.jsonevents.model.SensorEvent; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | @RestController 18 | @RequestMapping("/api/v1/events") 19 | public class SensorController { 20 | private final SensorEventProducer sensorEventProducer; 21 | private final SensorService sensorService; 22 | 23 | public SensorController(SensorEventProducer sensorEventProducer, SensorService sensorService) { 24 | this.sensorEventProducer = sensorEventProducer; 25 | this.sensorService = sensorService; 26 | } 27 | 28 | @PostMapping 29 | public ResponseEntity produce(@RequestBody SensorEvent event) { 30 | sensorEventProducer.send(event); 31 | return ResponseEntity.noContent().build(); 32 | } 33 | 34 | @GetMapping("/station/{stationId}") 35 | ResponseEntity> getEvents(@PathVariable String stationId) { 36 | List sensors = sensorService.byStationId(stationId); 37 | return ResponseEntity.ok(sensors); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/SensorEnricher.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.jsonevents; 2 | 3 | import java.util.List; 4 | import java.util.Objects; 5 | import java.util.UUID; 6 | 7 | import com.oracle.database.spring.jsonevents.model.Sensor; 8 | import com.oracle.database.spring.jsonevents.model.Station; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | public class SensorEnricher { 13 | private final StationService stationService; 14 | 15 | public SensorEnricher(StationService stationService) { 16 | this.stationService = stationService; 17 | } 18 | 19 | public Sensor enrich(Sensor sensor) { 20 | Objects.requireNonNull(sensor, "sensor cannot be null"); 21 | List query = stationService.byId(sensor.getStation().get_id()); 22 | if (query.isEmpty()) { 23 | throw new IllegalStateException("No weather station found for id " + sensor.getStation().get_id()); 24 | } 25 | sensor.setStation(query.get(0)); 26 | return sensor; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/SensorEventParser.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents; 4 | 5 | import java.util.List; 6 | import java.util.UUID; 7 | 8 | import com.oracle.database.spring.jsonevents.model.Sensor; 9 | import com.oracle.database.spring.jsonevents.model.SensorEvent; 10 | import com.oracle.database.spring.jsonevents.model.Station; 11 | import org.springframework.stereotype.Service; 12 | 13 | /** 14 | * Convert SensorEvents into Sensor lists 15 | */ 16 | @Service 17 | public class SensorEventParser { 18 | public List parse(SensorEvent sensorEvent) { 19 | return sensorEvent.getData().stream() 20 | .map(e -> e.split(",")) 21 | .filter(s -> s.length == 4) 22 | .map(s -> { 23 | Station st = new Station(); 24 | st.set_id(s[0]); 25 | 26 | Sensor sd = new Sensor(); 27 | sd.set_id(UUID.randomUUID().toString()); 28 | sd.setStation(st); 29 | sd.setTemperature(Double.parseDouble(s[1])); 30 | sd.setRelativeHumidity(Double.parseDouble(s[2])); 31 | sd.setUvIndex(Double.parseDouble(s[3])); 32 | return sd; 33 | }).toList(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/StationService.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents; 4 | 5 | import java.sql.PreparedStatement; 6 | import java.util.List; 7 | 8 | import com.oracle.database.spring.jsonevents.model.Station; 9 | import com.oracle.spring.json.jsonb.JSONB; 10 | import com.oracle.spring.json.jsonb.JSONBRowMapper; 11 | import org.springframework.jdbc.core.JdbcTemplate; 12 | import org.springframework.jdbc.core.RowMapper; 13 | import org.springframework.stereotype.Service; 14 | 15 | @Service 16 | public class StationService { 17 | private static final String stationById = """ 18 | select * from station_dv v 19 | where v.data."_id" = ? 20 | """; 21 | 22 | private final JdbcTemplate jdbcTemplate; 23 | private final RowMapper rowMapper; 24 | 25 | public StationService(JdbcTemplate jdbcTemplate, JSONB jsonb) { 26 | this.jdbcTemplate = jdbcTemplate; 27 | this.rowMapper = new JSONBRowMapper<>(jsonb, Station.class); 28 | } 29 | 30 | 31 | public List byId(String stationId) { 32 | return jdbcTemplate.query(con -> { 33 | PreparedStatement ps = con.prepareStatement(stationById); 34 | ps.setString(1, stationId); 35 | return ps; 36 | }, rowMapper); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/model/Sensor.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents.model; 4 | 5 | public class Sensor { 6 | String _id; 7 | String timestamp; 8 | double relativeHumidity; 9 | double temperature; 10 | double uvIndex; 11 | Station station; 12 | 13 | public String get_id() { 14 | return _id; 15 | } 16 | 17 | public void set_id(String _id) { 18 | this._id = _id; 19 | } 20 | 21 | public String getTimestamp() { 22 | return timestamp; 23 | } 24 | 25 | public void setTimestamp(String timestamp) { 26 | this.timestamp = timestamp; 27 | } 28 | 29 | public double getRelativeHumidity() { 30 | return relativeHumidity; 31 | } 32 | 33 | public void setRelativeHumidity(double relativeHumidity) { 34 | this.relativeHumidity = relativeHumidity; 35 | } 36 | 37 | public double getTemperature() { 38 | return temperature; 39 | } 40 | 41 | public void setTemperature(double temperature) { 42 | this.temperature = temperature; 43 | } 44 | 45 | public double getUvIndex() { 46 | return uvIndex; 47 | } 48 | 49 | public void setUvIndex(double uvIndex) { 50 | this.uvIndex = uvIndex; 51 | } 52 | 53 | public Station getStation() { 54 | return station; 55 | } 56 | 57 | public void setStation(Station station) { 58 | this.station = station; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/model/SensorEvent.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents.model; 4 | 5 | import java.util.List; 6 | 7 | public class SensorEvent { 8 | List data; 9 | 10 | public List getData() { 11 | return data; 12 | } 13 | 14 | public void setData(List data) { 15 | this.data = data; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/java/com/oracle/database/spring/jsonevents/model/Station.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.jsonevents.model; 4 | 5 | public class Station { 6 | String _id; 7 | String stationName; 8 | double latitude; 9 | double longitude; 10 | double elevation; 11 | 12 | public String get_id() { 13 | return _id; 14 | } 15 | 16 | public void set_id(String _id) { 17 | this._id = _id; 18 | } 19 | 20 | public String getStationName() { 21 | return stationName; 22 | } 23 | 24 | public void setStationName(String stationName) { 25 | this.stationName = stationName; 26 | } 27 | 28 | public double getLatitude() { 29 | return latitude; 30 | } 31 | 32 | public void setLatitude(double latitude) { 33 | this.latitude = latitude; 34 | } 35 | 36 | public double getLongitude() { 37 | return longitude; 38 | } 39 | 40 | public void setLongitude(double longitude) { 41 | this.longitude = longitude; 42 | } 43 | 44 | public double getElevation() { 45 | return elevation; 46 | } 47 | 48 | public void setElevation(double elevation) { 49 | this.elevation = elevation; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | jpa: 3 | hibernate: 4 | ddl-auto: none 5 | datasource: 6 | username: ${USERNAME} 7 | password: ${PASSWORD} 8 | url: ${JDBC_URL} 9 | 10 | # Set these to use UCP over Hikari. 11 | driver-class-name: oracle.jdbc.OracleDriver 12 | type: oracle.ucp.jdbc.PoolDataSourceImpl 13 | oracleucp: 14 | initial-pool-size: 1 15 | min-pool-size: 1 16 | max-pool-size: 30 17 | connection-pool-name: JSONEventsApplication 18 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 19 | server: 20 | port: 9001 21 | 22 | logging: 23 | level: 24 | org.apache.kafka: FATAL 25 | org.oracle.okafka: FATAL 26 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, stdout 2 | log4j.logger.org.apache.kafka=FATAL 3 | log4j.logger.org.oracle.okafka=FATAL 4 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/main/resources/ojdbc.properties: -------------------------------------------------------------------------------- 1 | user = testuser 2 | password = testpwd 3 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events/src/test/resources/txeventq.sql: -------------------------------------------------------------------------------- 1 | alter session set container=freepdb1; 2 | 3 | -- You may wish to modify the unlimited tablespace grant as appropriate. 4 | grant resource, connect, unlimited tablespace to TESTUSER; 5 | grant aq_user_role to TESTUSER; 6 | grant execute on dbms_aq to TESTUSER; 7 | grant execute on dbms_aqadm to TESTUSER; 8 | grant select on gv_$session to TESTUSER; 9 | grant select on v_$session to TESTUSER; 10 | grant select on gv_$instance to TESTUSER; 11 | grant select on gv_$listener_network to TESTUSER; 12 | grant select on SYS.DBA_RSRC_PLAN_DIRECTIVES to TESTUSER; 13 | grant select on gv_$pdbs to TESTUSER; 14 | grant select on user_queue_partition_assignment_table to TESTUSER; 15 | exec dbms_aqadm.GRANT_PRIV_FOR_RM_PLAN('TESTUSER'); 16 | commit; 17 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka/src/main/java/com/oracle/database/spring/okafka/OKafkaSampleApp.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.okafka; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.scheduling.annotation.EnableAsync; 8 | 9 | @SpringBootApplication 10 | @EnableAsync 11 | public class OKafkaSampleApp { 12 | public static void main(String[] args) { 13 | SpringApplication.run(OKafkaSampleApp.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka/src/main/java/com/oracle/database/spring/okafka/SampleProducer.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.okafka; 4 | 5 | import java.util.stream.Stream; 6 | 7 | import org.apache.kafka.clients.producer.Producer; 8 | import org.apache.kafka.clients.producer.ProducerRecord; 9 | 10 | /** 11 | * The SampleProducer reads from a given Stream, and writes each message to a topic. 12 | * Once the stream is complete, the producer exits. 13 | * 14 | * @param message type 15 | */ 16 | public class SampleProducer implements Runnable, AutoCloseable { 17 | private final Producer producer; 18 | private final String topic; 19 | private final Stream inputs; 20 | 21 | public SampleProducer(Producer producer, String topic, Stream inputs) { 22 | this.producer = producer; 23 | this.topic = topic; 24 | this.inputs = inputs; 25 | } 26 | 27 | @Override 28 | public void run() { 29 | inputs.forEach(t -> { 30 | System.out.println("Produced record: " + t); 31 | producer.send(new ProducerRecord<>(topic, t)); 32 | }); 33 | } 34 | 35 | @Override 36 | public void close() throws Exception { 37 | if (this.producer != null) { 38 | producer.close(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | org.apache.kafka: WARN 4 | org.oracle.okafka: WARN 5 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, stdout 2 | log4j.logger.org.apache.kafka=WARN 3 | log4j.logger.org.oracle.okafka=WARN 4 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka/src/main/resources/ojdbc.properties: -------------------------------------------------------------------------------- 1 | user = testuser 2 | password = Welcome123# 3 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka/src/test/resources/init.sql: -------------------------------------------------------------------------------- 1 | alter session set container=freepdb1; 2 | 3 | -- You may wish to modify the unlimited tablespace grant as appropriate. 4 | grant resource, connect, unlimited tablespace to TESTUSER; 5 | grant aq_user_role to TESTUSER; 6 | grant execute on dbms_aq to TESTUSER; 7 | grant execute on dbms_aqadm to TESTUSER; 8 | grant select on gv_$session to TESTUSER; 9 | grant select on v_$session to TESTUSER; 10 | grant select on gv_$instance to TESTUSER; 11 | grant select on gv_$listener_network to TESTUSER; 12 | grant select on SYS.DBA_RSRC_PLAN_DIRECTIVES to TESTUSER; 13 | grant select on gv_$pdbs to TESTUSER; 14 | grant select on user_queue_partition_assignment_table to TESTUSER; 15 | exec dbms_aqadm.GRANT_PRIV_FOR_RM_PLAN('TESTUSER'); 16 | commit; 17 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/consumer/src/main/java/com/oracle/database/spring/txeventqjms/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.txeventqjms.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConsumerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConsumerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/consumer/src/main/java/com/oracle/database/spring/txeventqjms/consumer/service/Consumer.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.txeventqjms.consumer.service; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.jms.annotation.JmsListener; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class Consumer { 10 | 11 | private static final Logger log = LoggerFactory.getLogger(Consumer.class); 12 | 13 | @JmsListener(destination = "${txeventq.topic.name}") 14 | public void receiveMessage(String message) { 15 | log.info("Received message: {}", message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/consumer/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: consumer 4 | 5 | datasource: 6 | url: jdbc:oracle:thin:@//localhost:1521/freepdb1 7 | username: testuser 8 | password: Welcome12345 9 | driver-class-name: oracle.jdbc.OracleDriver 10 | type: oracle.ucp.jdbc.PoolDataSource 11 | oracleucp: 12 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 13 | connection-pool-name: ConsumerConnectionPool 14 | initial-pool-size: 15 15 | min-pool-size: 10 16 | max-pool-size: 30 17 | 18 | txeventq: 19 | topic: 20 | name: my_txeventq -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/consumer/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ____ 2 | / ___|___ _ __ ___ _ _ _ __ ___ ___ _ __ 3 | | | / _ \| '_ \/ __| | | | '_ ` _ \ / _ \ '__| 4 | | |__| (_) | | | \__ \ |_| | | | | | | __/ | 5 | \____\___/|_| |_|___/\__,_|_| |_| |_|\___|_| 6 | 7 | Powered by Spring Boot ${spring-boot.version} 8 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 4.0.0 7 | 8 | oracle-spring-boot-starter-samples 9 | com.oracle.database.spring 10 | 25.2.0 11 | ../pom.xml 12 | 13 | 14 | oracle-spring-boot-sample-txeventqjms 15 | 25.2.0 16 | pom 17 | 18 | Oracle Spring Boot Starter - Transactional Event Queue JMS Sample 19 | Oracle Spring Boot Starter - Transactional Event Queue JMS Sample 20 | 21 | 22 | consumer 23 | producer 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-deploy-plugin 33 | 34 | true 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/producer/src/main/java/com/oracle/database/spring/txeventq/producer/ProducerApplication.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.txeventq.producer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProducerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProducerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/producer/src/main/java/com/oracle/database/spring/txeventq/producer/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.txeventq.producer.controller; 2 | 3 | import com.oracle.database.spring.txeventq.producer.service.Producer; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @RequestMapping("/api/v1") 11 | public class MessageController { 12 | Producer producer; 13 | 14 | public MessageController(Producer producer) { 15 | this.producer = producer; 16 | } 17 | 18 | @PostMapping("/message") 19 | public String receiveMessage(@RequestParam("message") String message) { 20 | producer.sendMessageToTopic(message); 21 | return "Message was sent successfully"; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/producer/src/main/java/com/oracle/database/spring/txeventq/producer/service/Producer.java: -------------------------------------------------------------------------------- 1 | package com.oracle.database.spring.txeventq.producer.service; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.jms.core.JmsTemplate; 8 | 9 | @Service 10 | public class Producer { 11 | 12 | private static final Logger log = LoggerFactory.getLogger(Producer.class); 13 | 14 | JmsTemplate jmsTemplate; 15 | 16 | @Value("${txeventq.topic.name}") 17 | private String topic; 18 | 19 | public Producer(JmsTemplate jmsTemplate) { 20 | this.jmsTemplate = jmsTemplate; 21 | } 22 | 23 | public void sendMessageToTopic(String message) 24 | { 25 | jmsTemplate.convertAndSend(topic,message); 26 | log.info("Sending message: {} to topic {}", message, topic); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/producer/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: producer 4 | 5 | datasource: 6 | url: jdbc:oracle:thin:@//localhost:1521/freepdb1 7 | username: testuser 8 | password: testpwd 9 | driver-class-name: oracle.jdbc.OracleDriver 10 | type: oracle.ucp.jdbc.PoolDataSource 11 | oracleucp: 12 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 13 | connection-pool-name: ConsumerConnectionPool 14 | initial-pool-size: 15 15 | min-pool-size: 10 16 | max-pool-size: 30 17 | 18 | txeventq: 19 | topic: 20 | name: my_txeventq -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/producer/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ____ _ 2 | | _ \ _ __ ___ __| |_ _ ___ ___ _ __ 3 | | |_) | '__/ _ \ / _` | | | |/ __/ _ \ '__| 4 | | __/| | | (_) | (_| | |_| | (_| __/ | 5 | |_| |_| \___/ \__,_|\__,_|\___\___|_| 6 | 7 | Powered by Spring Boot ${spring-boot.version} 8 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-txeventqjms/sql/setup.sql: -------------------------------------------------------------------------------- 1 | -- This must be executed as SYS 2 | create user testuser identified by Welcome12345; 3 | grant resource, connect, unlimited tablespace to testuser; 4 | grant aq_user_role to testuser; 5 | grant execute on dbms_aq to testuser; 6 | grant execute on dbms_aqadm to testuser; 7 | grant execute ON dbms_aqin TO testuser; 8 | grant execute ON dbms_aqjms TO testuser; 9 | grant execute on dbms_teqk to testuser; 10 | commit; 11 | 12 | -- create the TEQ 13 | begin 14 | dbms_aqadm.create_transactional_event_queue( 15 | queue_name => 'TESTUSER.MY_TXEVENTQ', 16 | -- when mutiple_consumers is true, this will create a pub/sub "topic" - the default is false 17 | multiple_consumers => false 18 | ); 19 | 20 | -- start the TEQ 21 | dbms_aqadm.start_queue( 22 | queue_name => 'TESTUSER.MY_TXEVENTQ' 23 | ); 24 | end; 25 | / 26 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-ucp-jpa/src/main/java/com/oracle/database/spring/sample/StudentRepository.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.sample; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | public interface StudentRepository extends JpaRepository { 8 | } 9 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-ucp-jpa/src/main/java/com/oracle/database/spring/sample/UCPSampleApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.database.spring.sample; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | public class UCPSampleApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(UCPSampleApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-ucp-jpa/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | jpa: 3 | hibernate: 4 | ddl-auto: none 5 | datasource: 6 | username: ${USERNAME} 7 | password: ${PASSWORD} 8 | url: ${JDBC_URL} 9 | 10 | # Set these to use UCP over Hikari. 11 | driver-class-name: oracle.jdbc.OracleDriver 12 | type: oracle.ucp.jdbc.PoolDataSourceImpl 13 | oracleucp: 14 | initial-pool-size: 1 15 | min-pool-size: 1 16 | max-pool-size: 30 17 | connection-pool-name: UCPSampleApplication 18 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 19 | server: 20 | port: 9001 21 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-ucp-jpa/src/test/resources/init.sql: -------------------------------------------------------------------------------- 1 | create table student ( 2 | id varchar2(36) primary key, 3 | first_name varchar2(50) not null, 4 | last_name varchar2(50) not null, 5 | email varchar2(100), 6 | major varchar2(20) not null, 7 | credits number(10), 8 | gpa number(10) 9 | ); 10 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-wallet/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: oracle-spring-boot-samples-wallet 4 | 5 | # Datasource Configuration 6 | datasource: 7 | url: jdbc:oracle:thin:@?TNS_ADMIN= 8 | username: ADMIN 9 | password: 10 | driver-class-name: oracle.jdbc.OracleDriver 11 | type: oracle.ucp.jdbc.PoolDataSource 12 | oracleucp: 13 | connection-factory-class-name: oracle.jdbc.pool.OracleDataSource 14 | connection-pool-name: UCPWalletConnectionPool 15 | initial-pool-size: 15 16 | min-pool-size: 10 17 | max-pool-size: 30 -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-ucp/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.oracle.spring.ucp.UCPAutoConfiguration -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-ucp/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.oracle.spring.ucp.UCPAutoConfiguration -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-ucp/src/test/java/com/oracle/spring/ucp/Config.java: -------------------------------------------------------------------------------- 1 | package com.oracle.spring.ucp; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import oracle.ucp.jdbc.PoolDataSourceFactory; 6 | import org.springframework.boot.test.context.TestConfiguration; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @TestConfiguration 10 | public class Config { 11 | @Bean 12 | DataSource dataSource() { 13 | return PoolDataSourceFactory.getPoolDataSource(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /database/starters/oracle-spring-boot-starter-ucp/src/test/java/com/oracle/spring/ucp/UCPAutoConfigurationTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 | package com.oracle.spring.ucp; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import oracle.ucp.jdbc.PoolDataSourceImpl; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.context.annotation.Import; 13 | import org.springframework.test.context.TestPropertySource; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | @SpringBootTest(classes = UCPAutoConfiguration.class) 18 | @Import(Config.class) 19 | public class UCPAutoConfigurationTest { 20 | @Autowired 21 | DataSource dataSource; 22 | 23 | @Test 24 | void dataSourceConfigured() { 25 | assertThat(dataSource).isNotNull(); 26 | if (dataSource instanceof PoolDataSourceImpl ds) { 27 | assertThat(ds.getInitialPoolSize()).isEqualTo(15); 28 | assertThat(ds.getConnectionFactoryClassName()).isEqualTo("oracle.jdbc.pool.OracleDataSource"); 29 | assertThat(ds.getConnectionPoolName()).isEqualTo("SpringConnectionPool"); 30 | } else { 31 | Assertions.fail("Datasource is not a PoolDataSourceImpl: " + dataSource.getClass().getName()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/starters/scripts/deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2024, Oracle and/or its affiliates. 3 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | 5 | set -euo pipefail 6 | 7 | usage() { 8 | echo "Usage: $0 -v version -u repository.url -r repository.name " 9 | exit 1 10 | } 11 | 12 | VERSION="" 13 | REPOSITORY_NAME="" 14 | REPOSITORY_URL="" 15 | 16 | if [ -z "$(command -v mvn)" ]; then 17 | echo "Error: 'mvn' binary not found on PATH. Install 'mvn' before running this script." 18 | fi 19 | 20 | while getopts ":v:r:u:" opt; do 21 | case $opt in 22 | v) VERSION="$OPTARG";; 23 | u) REPOSITORY_URL="$OPTARG";; 24 | r) REPOSITORY_NAME="$OPTARG";; 25 | \?) echo "Invalid option -$OPTARG" >&2; usage;; 26 | :) echo "Option -$OPTARG requires an argument." >&2; usage;; 27 | esac 28 | done 29 | 30 | if [ -z "$VERSION" ] || [ -z "$REPOSITORY_URL" ] || [ -z "$REPOSITORY_NAME" ]; then 31 | echo "Error: -v, -u, and -r options are required." 32 | usage 33 | fi 34 | 35 | echo "Setting project version = $VERSION" 36 | 37 | mvn -q versions:set -DnewVersion="$VERSION" 38 | 39 | echo "Successfully set project version = $VERSION" 40 | 41 | echo "Deploying project to ${REPOSITORY_URL}/${REPOSITORY_NAME}" 42 | 43 | mvn -q deploy -Drepository.url="$REPOSITORY_URL" -Drepository.name="$REPOSITORY_NAME" -DskipTests 44 | 45 | echo "Successfully deployed project to ${REPOSITORY_URL}/${REPOSITORY_NAME}" 46 | 47 | # shellcheck disable=SC2016 48 | PACKAGES="$(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q)" 49 | printf "The following artifacts have been created for upload:\n\n" 50 | for PACKAGE in $PACKAGES; do 51 | if [[ "$PACKAGE" != *"-sample"* ]]; then 52 | echo "com.oracle.database.spring:${PACKAGE}:${VERSION}" 53 | fi 54 | done 55 | -------------------------------------------------------------------------------- /recipes/hikariucp/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | *.log 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | .idea 16 | .idea/** 17 | 18 | ### Eclipse ### 19 | .apt_generated 20 | .classpath 21 | .factorypath 22 | .project 23 | .settings 24 | .springBeans 25 | .sts4-cache 26 | 27 | ### NetBeans ### 28 | /nbproject/private/ 29 | /nbbuild/ 30 | /dist/ 31 | /nbdist/ 32 | /.nb-gradle/ 33 | build/ 34 | !**/src/main/**/build/ 35 | !**/src/test/**/build/ 36 | 37 | ### VS Code ### 38 | .vscode/ 39 | /.jpb/** 40 | 41 | ### Mac OS ### 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /recipes/hikariucp/src/test/oracle/com/cloud/recipes/hikariucp/ChangePropertyValueTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | package oracle.com.cloud.recipes.hikariucp; 5 | 6 | import org.openrewrite.test.RewriteTest; 7 | 8 | import static org.openrewrite.properties.Assertions.properties; 9 | import static org.openrewrite.yaml.Assertions.yaml; 10 | 11 | class ChangeSpringPropertyValueTest implements RewriteTest { 12 | 13 | // @DocumentExample 14 | // @Test 15 | // void propFile() { 16 | // rewriteRun( 17 | // spec -> spec.recipe(new ChangeSpringPropertyValue("server.port", "8081", null, null, null)), 18 | // properties("server.port=8080", "server.port=8081") 19 | // ); 20 | 21 | 22 | } -------------------------------------------------------------------------------- /spring-cli/catalog/project-catalog.yml: -------------------------------------------------------------------------------- 1 | --- 2 | project-repositories: 3 | - name: "obaas" 4 | description: "RESTful Greeting service for Oracle Backend Microservices and AI" 5 | url: "https://github.com/oracle/spring-cloud-oci/tree/main/spring-cli/projects/obaas" 6 | tags: 7 | - "obaas" 8 | - "java-17" 9 | - "rest" 10 | - "web" 11 | - "boot-3.4.x" 12 | -------------------------------------------------------------------------------- /spring-cli/projects/obaas/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/main/java/com/example/restservice/Application.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/main/java/com/example/restservice/controller/GreetingController.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice.controller; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import com.example.restservice.model.Greeting; 10 | 11 | @RestController 12 | public class GreetingController { 13 | 14 | private static final String template = "Hello, %s!"; 15 | private final AtomicLong counter = new AtomicLong(); 16 | 17 | /** 18 | * Create and return greeting with a counter. 19 | * 20 | * @param name String name 21 | * @return Returns Greeting record with optional name 22 | */ 23 | @GetMapping("/greeting") 24 | public Greeting greeting(@RequestParam(defaultValue = "World") String name) { 25 | return new Greeting(counter.incrementAndGet(), template.formatted(name)); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/main/java/com/example/restservice/model/Greeting.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice.model; 2 | 3 | public record Greeting (Long id, String Content){ 4 | } 5 | -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/main/resources/db/changelog/controller.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | databaseChangeLog: 3 | - include: 4 | file: classpath:db/changelog/table.sql 5 | - include: 6 | file: classpath:db/changelog/data.sql -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/main/resources/db/changelog/data.sql: -------------------------------------------------------------------------------- 1 | -- liquibase formatted sql 2 | 3 | -- changeset springcliapp:1 runAlways:true 4 | truncate table mytable; 5 | 6 | insert into mytable (a,b,c,d) 7 | values ('1','2','3','4'); 8 | commit; 9 | 10 | --rollback DELETE FROM mytable; -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/main/resources/db/changelog/table.sql: -------------------------------------------------------------------------------- 1 | -- liquibase formatted sql 2 | 3 | --changeset springcliapp:1 4 | --preconditions onfail:MARK_RAN onerror:MARK_RAN 5 | --precondition-sql-check expectedresult:0 select count(*) from mytable where 1=2 6 | drop table mytable; 7 | 8 | --changeset springcliapp:2 9 | create table mytable ( 10 | a varchar2 (20), 11 | b varchar2 (40), 12 | c varchar2 (40), 13 | d varchar2(40) 14 | ) logging; 15 | 16 | alter table mytable add constraint mytable_pk primary key (a) using index logging; 17 | 18 | --rollback drop table mytable; -------------------------------------------------------------------------------- /spring-cli/projects/obaas/src/test/java/com/example/restservice/greeting/GreetingControllerTests.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice.greeting; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.web.servlet.MockMvc; 8 | 9 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 10 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 11 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 12 | 13 | @SpringBootTest 14 | @AutoConfigureMockMvc 15 | public class GreetingControllerTests { 16 | 17 | @Autowired 18 | private MockMvc mockMvc; 19 | 20 | @Test 21 | public void noParamGreetingShouldReturnDefaultMessage() throws Exception { 22 | mockMvc.perform(get("/greeting")) 23 | .andExpect(status().isOk()) 24 | .andExpect(jsonPath("$.id").value(1)) 25 | .andExpect(jsonPath("$.Content").value("Hello, World!")); 26 | 27 | } 28 | 29 | @Test 30 | public void paramGreetingShouldReturnTailoredMessage() throws Exception { 31 | String name = "Spring Community"; 32 | String expectedGreeting = "Hello, " + name + "!"; 33 | 34 | mockMvc.perform(get("/greeting").param("name", name)) 35 | .andExpect(status().isOk()) 36 | .andExpect(jsonPath("$.id").value(2)) 37 | .andExpect(jsonPath("$.Content").value(expectedGreeting)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-oci/Makefile: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- 2 | # Copyright (c) 2023, Oracle and/or its affiliates. 3 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | # ---------------------------------------------------------------------------- 5 | 6 | .PHONY: clean build docs 7 | 8 | mvncmd=mvnd 9 | 10 | ifeq (, $(shell which ${mvncmd})) 11 | mvncmd=mvn 12 | endif 13 | 14 | 15 | build: 16 | ${mvncmd} verify -DskipTests 17 | 18 | clean: 19 | ${mvncmd} clean 20 | 21 | docs: 22 | ${mvncmd} verify -Pasciidocs -DskipTests=true 23 | 24 | javadocs: 25 | ${mvncmd} clean package javadoc:aggregate -DskipTests=true -e 26 | -------------------------------------------------------------------------------- /spring-cloud-oci/docs/generate-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Copyright (c) 2023, Oracle and/or its affiliates. 4 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 5 | 6 | # This command regenerates the docs after editing. 7 | # You'll have to run this after editing the src/main/asciidoc/README.adoc 8 | 9 | mvn clean install -Pasciidocs 10 | -------------------------------------------------------------------------------- /spring-cloud-oci/docs/src/main/asciidoc/Guardfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | require 'asciidoctor' 5 | require 'erb' 6 | 7 | guard 'shell' do 8 | watch(/.*\.adoc$/) {|m| 9 | Asciidoctor.render_file('index.adoc', \ 10 | :in_place => true, \ 11 | :safe => Asciidoctor::SafeMode::UNSAFE, \ 12 | :attributes=> { \ 13 | 'source-highlighter' => 'prettify', \ 14 | 'icons' => 'font', \ 15 | 'linkcss'=> 'true', \ 16 | 'copycss' => 'true', \ 17 | 'doctype' => 'book'}) 18 | } 19 | end 20 | 21 | guard 'livereload' do 22 | watch(%r{^.+\.(css|js|html)$}) 23 | end 24 | -------------------------------------------------------------------------------- /spring-cloud-oci/docs/src/main/asciidoc/_attributes.adoc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | :doctype: book 5 | :idprefix: 6 | :idseparator: - 7 | :toc: left 8 | :toclevels: 4 9 | :tabsize: 4 10 | :numbered: 11 | :sectanchors: 12 | :sectnums: 13 | :icons: font 14 | :hide-uri-scheme: 15 | :docinfo: shared,private 16 | 17 | :sc-ext: java 18 | :project-full-name: Spring Cloud Oracle 19 | :all: {asterisk}{asterisk} -------------------------------------------------------------------------------- /spring-cloud-oci/docs/src/main/asciidoc/appendix.adoc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | :numbered!: 5 | [appendix] 6 | [[common-application-properties]] 7 | == Common application properties 8 | 9 | include::_attributes.adoc[] 10 | 11 | Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches. 12 | This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them. 13 | 14 | NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. 15 | Also, you can define your own properties. 16 | 17 | include::_configprops.adoc[] -------------------------------------------------------------------------------- /spring-cloud-oci/docs/src/main/asciidoc/configuration.adoc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | == Configuration properties 5 | 6 | To see the list of all OCI related configuration properties please check link:appendix.html[the Appendix page]. -------------------------------------------------------------------------------- /spring-cloud-oci/docs/src/main/asciidoc/index-docinfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spring Cloud Oracle 5 | {project-version} 6 | 7 | 2022-2024 8 | Oracle 9 | 10 | 11 | 12 | Copies of this document may be made for your own use and for distribution to 13 | others, provided that you do not charge any fee for such copies and further 14 | provided that each copy contains this Copyright Notice, whether distributed in 15 | print or electronically. 16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-cloud-oci/docs/src/main/asciidoc/wallet.adoc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | [#wallet] 5 | == Oracle Database Wallet 6 | 7 | This starter provides authentication mechanisms for Oracle Database connections using Oracle Database Wallet, such as connections to Autonomous Database with mTLS enabled. 8 | 9 | To add this starter to your project, add this Maven dependency: 10 | 11 | [source,xml] 12 | ---- 13 | 14 | com.oracle.database.spring 15 | oracle-spring-boot-starter-wallet 16 | 24.4.0 17 | 18 | ---- 19 | 20 | For Gradle projects, add this dependency: 21 | 22 | [source,subs="normal"] 23 | ---- 24 | dependencies { 25 | implementation 'com.oracle.database.spring:oracle-spring-boot-starter-wallet:24.4.0' 26 | } 27 | ---- 28 | -------------------------------------------------------------------------------- /spring-cloud-oci/scripts/version: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION="$1" 4 | 5 | if [ -z "$VERSION" ]; then 6 | echo "Usage: ./scripts/version " 7 | exit 1 8 | fi 9 | if [ -z "$(command -v mvn)" ]; then 10 | echo "Error: 'mvn' binary not found on PATH. Install 'mvn' before running this script." 11 | exit 1 12 | fi 13 | 14 | echo "Setting project version = $VERSION" 15 | 16 | mvn -q versions:set -DnewVersion="$VERSION" 17 | cd spring-cloud-oci-dependencies 18 | mvn -q versions:set -DnewVersion="$VERSION" 19 | cd - 20 | cd docs 21 | mvn -q versions:set -DnewVersion="$VERSION" 22 | cd - 23 | 24 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-adb/src/main/java/com/oracle/cloud/spring/adb/AutonomousDbDetails.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | package com.oracle.cloud.spring.adb; 5 | 6 | public record AutonomousDbDetails ( 7 | String compartmentId, 8 | String displayName, 9 | String id, 10 | String dbName, 11 | String lifecycleState, 12 | String timeCreated, 13 | Float computeCount, 14 | Integer dataStorageSizeInGBs, 15 | String licenseModel, 16 | String serviceConsoleUrl 17 | ) { } 18 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CompartmentProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.autoconfigure.core; 7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | import org.springframework.lang.Nullable; 10 | import org.springframework.util.StringUtils; 11 | 12 | /** 13 | * Auto-configuration settings related to a Compartment. 14 | */ 15 | @ConfigurationProperties(prefix = CompartmentProperties.PREFIX) 16 | public class CompartmentProperties { 17 | public static final String PREFIX = "spring.cloud.oci.compartment"; 18 | 19 | @Nullable 20 | private String staticCompartment; 21 | 22 | @Nullable 23 | public String getStatic() { 24 | return staticCompartment; 25 | } 26 | 27 | public boolean isStatic() { 28 | return StringUtils.hasText(staticCompartment); 29 | } 30 | 31 | public void setStatic(String staticCompartment) { 32 | this.staticCompartment = staticCompartment; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/RegionProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.autoconfigure.core; 7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | import org.springframework.lang.Nullable; 10 | import org.springframework.util.StringUtils; 11 | 12 | /** 13 | * Auto-configuration settings related to a Region. 14 | */ 15 | @ConfigurationProperties(prefix = RegionProperties.PREFIX) 16 | public class RegionProperties { 17 | public static final String PREFIX = "spring.cloud.oci.region"; 18 | 19 | @Nullable 20 | private String staticRegion; 21 | 22 | @Nullable 23 | public String getStatic() { 24 | return staticRegion; 25 | } 26 | 27 | public boolean isStatic() { 28 | return StringUtils.hasText(staticRegion); 29 | } 30 | 31 | public void setStatic(String staticRegion) { 32 | this.staticRegion = staticRegion; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/email/MailSenderProperties.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.email; 4 | 5 | 6 | import java.util.Objects; 7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | import org.springframework.util.StringUtils; 10 | 11 | @ConfigurationProperties(prefix = MailSenderProperties.PREFIX) 12 | public class MailSenderProperties { 13 | public static final String PREFIX = "spring.mail"; 14 | 15 | private String host; 16 | private String username; 17 | private String password; 18 | private Integer port; 19 | 20 | public String getHost() { 21 | return host; 22 | } 23 | 24 | public void setHost(String host) { 25 | this.host = host; 26 | } 27 | 28 | public String getUsername() { 29 | return username; 30 | } 31 | 32 | public void setUsername(String username) { 33 | this.username = username; 34 | } 35 | 36 | public String getPassword() { 37 | return password; 38 | } 39 | 40 | public void setPassword(String password) { 41 | this.password = password; 42 | } 43 | 44 | public Integer getPort() { 45 | return Objects.requireNonNullElse(port, 587); 46 | } 47 | 48 | public void setPort(Integer port) { 49 | this.port = port; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/logging/LoggingProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.logging; 7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | import org.springframework.lang.Nullable; 10 | 11 | /** 12 | * Auto-configuration settings related to Logging component. 13 | */ 14 | @ConfigurationProperties(prefix = LoggingProperties.PREFIX) 15 | public class LoggingProperties { 16 | public static final String PREFIX = "spring.cloud.oci.logging"; 17 | 18 | 19 | @Nullable 20 | private String logId; 21 | 22 | @Nullable 23 | public String getLogId() { 24 | return logId; 25 | } 26 | 27 | public void setLogId(@Nullable String logId) { 28 | this.logId = logId; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/vault/VaultEnvironmentPostProcessor.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.vault; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor; 7 | import org.springframework.boot.env.EnvironmentPostProcessor; 8 | import org.springframework.core.Ordered; 9 | import org.springframework.core.env.ConfigurableEnvironment; 10 | import org.springframework.util.ClassUtils; 11 | 12 | /** 13 | * Injects a VaultPropertySource for each OCI Vault property source specified in the application properties. 14 | * OCI Vault property sources will only be loaded if the com.oracle.cloud.spring.vault.VaulTemplate class is on the classpath. 15 | */ 16 | public class VaultEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered { 17 | @Override 18 | public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { 19 | if (areClassesLoaded()) { 20 | VaultPropertySource.configure(environment); 21 | } 22 | } 23 | 24 | @Override 25 | public int getOrder() { 26 | return ConfigDataEnvironmentPostProcessor.ORDER + 1; 27 | } 28 | 29 | private boolean areClassesLoaded() { 30 | return ClassUtils.isPresent("com.oracle.cloud.spring.vault.VaultTemplate", VaultEnvironmentPostProcessor.class.getClassLoader()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/vault/VaultProperties.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.vault; 4 | 5 | import java.time.Duration; 6 | import java.util.List; 7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | 10 | @ConfigurationProperties(prefix = VaultProperties.PREFIX) 11 | public class VaultProperties { 12 | public static final String PREFIX = "spring.cloud.oci.vault"; 13 | 14 | private String compartment; 15 | private String vaultId; 16 | 17 | private List propertySources; 18 | 19 | private Duration propertyRefreshInterval; 20 | 21 | public String getCompartment() { 22 | return compartment; 23 | } 24 | 25 | public void setCompartment(String compartment) { 26 | this.compartment = compartment; 27 | } 28 | 29 | public String getVaultId() { 30 | return vaultId; 31 | } 32 | 33 | public void setVaultId(String vaultId) { 34 | this.vaultId = vaultId; 35 | } 36 | 37 | public List getPropertySources() { 38 | return propertySources; 39 | } 40 | 41 | public void setPropertySources(List propertySources) { 42 | this.propertySources = propertySources; 43 | } 44 | 45 | public Duration getPropertyRefreshInterval() { 46 | return propertyRefreshInterval; 47 | } 48 | 49 | public void setPropertyRefreshInterval(Duration propertyRefreshInterval) { 50 | this.propertyRefreshInterval = propertyRefreshInterval; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/vault/VaultPropertySourceProperties.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.vault; 4 | 5 | public class VaultPropertySourceProperties { 6 | private String vaultId; 7 | 8 | public String getVaultId() { 9 | return vaultId; 10 | } 11 | 12 | public void setVaultId(String vaultId) { 13 | this.vaultId = vaultId; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.env.EnvironmentPostProcessor=com.oracle.cloud.spring.vault.VaultEnvironmentPostProcessor -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.oracle.cloud.spring.autoconfigure.core.CompartmentProviderAutoConfiguration 2 | com.oracle.cloud.spring.autoconfigure.core.RegionProviderAutoConfiguration 3 | com.oracle.cloud.spring.autoconfigure.core.CredentialsProviderAutoConfiguration 4 | com.oracle.cloud.spring.notification.NotificationAutoConfiguration 5 | com.oracle.cloud.spring.storage.StorageAutoConfiguration 6 | com.oracle.cloud.spring.logging.LoggingAutoConfiguration 7 | com.oracle.cloud.spring.function.FunctionAutoConfiguration 8 | com.oracle.cloud.spring.streaming.StreamingAutoConfiguration 9 | com.oracle.cloud.spring.queue.QueueAutoConfiguration 10 | com.oracle.cloud.spring.genai.GenAIAutoConfiguration 11 | com.oracle.cloud.spring.vault.VaultAutoConfiguration 12 | com.oracle.cloud.spring.adb.AutonomousDbAutoConfiguration 13 | com.oracle.cloud.spring.email.EmailDeliveryAutoConfiguration 14 | com.oracle.cloud.spring.nosql.NoSQLAutoConfiguration 15 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/test/java/com/oracle/cloud/spring/email/EmailDeliveryAutoConfigurationTests.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.email; 4 | 5 | import com.oracle.cloud.spring.autoconfigure.TestCommonConfigurationBeans; 6 | import com.oracle.cloud.spring.vault.VaultAutoConfiguration; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; 9 | import org.springframework.boot.autoconfigure.AutoConfigurations; 10 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; 11 | import org.springframework.mail.MailSender; 12 | import org.springframework.mail.javamail.JavaMailSender; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | 16 | public class EmailDeliveryAutoConfigurationTests { 17 | private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() 18 | .withConfiguration(AutoConfigurations.of(EmailDeliveryAutoConfiguration.class)) 19 | .withUserConfiguration(TestCommonConfigurationBeans.class); 20 | 21 | @Test 22 | void beansAreLoaded() { 23 | contextRunner.run(context -> { 24 | JavaMailSender javaMailSender = BeanFactoryAnnotationUtils.qualifiedBeanOfType(context.getBeanFactory(), JavaMailSender.class, "ociJavaMailSender"); 25 | assertThat(javaMailSender instanceof EmailDeliveryJavaMailSender).isTrue(); 26 | MailSender mailSender = BeanFactoryAnnotationUtils.qualifiedBeanOfType(context.getBeanFactory(), MailSender.class, "ociMailSender"); 27 | assertThat(mailSender instanceof EmailDeliveryMailSender).isTrue(); 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-autoconfigure/src/test/java/com/oracle/cloud/spring/nosql/NoSQLAutoConfigurationTests.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.nosql; 4 | 5 | import com.oracle.cloud.spring.autoconfigure.TestCommonConfigurationBeans; 6 | import com.oracle.nosql.spring.data.config.NosqlDbConfig; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.boot.autoconfigure.AutoConfigurations; 9 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; 10 | 11 | import static com.oracle.cloud.spring.autoconfigure.TestCommonConfigurationBeans.assertBeanLoaded; 12 | import static com.oracle.cloud.spring.autoconfigure.TestCommonConfigurationBeans.assertBeanNotLoaded; 13 | 14 | public class NoSQLAutoConfigurationTests { 15 | private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() 16 | .withPropertyValues("spring.cloud.oci.nosql.enabled=true") 17 | .withConfiguration(AutoConfigurations.of(NoSQLAutoConfiguration.class)) 18 | .withUserConfiguration(TestCommonConfigurationBeans.class); 19 | 20 | @Test 21 | void beansAreLoaded() { 22 | contextRunner.run(ctx -> assertBeanLoaded(ctx, NosqlDbConfig.class)); 23 | } 24 | 25 | @Test 26 | void beansAreNotLoadedWhenDisabled() { 27 | contextRunner.withPropertyValues("spring.cloud.oci.nosql.enabled=false") 28 | .run(ctx -> assertBeanNotLoaded(ctx, NosqlDbConfig.class)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-core/src/main/java/com/oracle/cloud/spring/core/compartment/CompartmentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.core.compartment; 7 | 8 | /** 9 | * Interface to provide Compartment details, like OCID, for Compartment configuration. 10 | */ 11 | public interface CompartmentProvider { 12 | 13 | String getCompartmentOCID(); 14 | } 15 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-core/src/main/java/com/oracle/cloud/spring/core/compartment/StaticCompartmentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.core.compartment; 7 | 8 | import org.springframework.util.Assert; 9 | 10 | /** 11 | * Provider to wrap Compartment details like OCID for Compartment configuration 12 | */ 13 | public class StaticCompartmentProvider implements CompartmentProvider { 14 | 15 | public static final String COMPARTMENT_MISSING_MSG = "compartmentOCID is required"; 16 | private final String compartmentOCID; 17 | 18 | public StaticCompartmentProvider(String compartmentOCID) { 19 | Assert.notNull(compartmentOCID, COMPARTMENT_MISSING_MSG); 20 | this.compartmentOCID = compartmentOCID; 21 | } 22 | 23 | @Override 24 | public String getCompartmentOCID() { 25 | return compartmentOCID; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-core/src/main/java/com/oracle/cloud/spring/core/region/StaticRegionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.core.region; 7 | 8 | import com.oracle.bmc.Region; 9 | import com.oracle.bmc.auth.RegionProvider; 10 | 11 | 12 | /** 13 | * Provider to wrap Region details like name for Region configuration 14 | */ 15 | public class StaticRegionProvider implements RegionProvider { 16 | 17 | public static final String INVALID_REGION_MSG = "The region '%s' is not a valid region!"; 18 | private Region region; 19 | 20 | public StaticRegionProvider(String regionName) { 21 | try { 22 | region = Region.valueOf(regionName); 23 | } catch (IllegalArgumentException e) { 24 | throw new IllegalArgumentException(INVALID_REGION_MSG.formatted(regionName), e); 25 | } 26 | } 27 | 28 | public StaticRegionProvider() { 29 | } 30 | 31 | @Override 32 | public Region getRegion() { 33 | return region; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-core/src/test/java/com/oracle/cloud/spring/core/compartment/CompartmentProviderTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.core.compartment; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import static org.junit.jupiter.api.Assertions.*; 10 | 11 | class CompartmentProviderTests { 12 | 13 | @Test 14 | void testCompartmentProviderWithNullCompartmentId(){ 15 | Exception exception = assertThrows(IllegalArgumentException.class, () -> { 16 | new StaticCompartmentProvider(null); 17 | }); 18 | 19 | String actualMessage = exception.getMessage(); 20 | 21 | assertEquals(actualMessage, StaticCompartmentProvider.COMPARTMENT_MISSING_MSG); 22 | } 23 | 24 | @Test 25 | void testCompartmentProviderWithCompartmentId(){ 26 | 27 | CompartmentProvider compartmentProvider = 28 | new StaticCompartmentProvider("dummyCompartmentId"); 29 | 30 | assertNotNull(compartmentProvider.getCompartmentOCID()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-core/src/test/java/com/oracle/cloud/spring/core/region/RegionProviderTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.core.region; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import static org.junit.jupiter.api.Assertions.*; 11 | 12 | class RegionProviderTests { 13 | 14 | @Test 15 | void testInvalidRegion(){ 16 | final String region = "foo"; 17 | Exception exception = assertThrows(IllegalArgumentException.class, () -> { 18 | new StaticRegionProvider(region); 19 | }); 20 | 21 | String actualMessage = exception.getMessage(); 22 | 23 | assertEquals(actualMessage, StaticRegionProvider.INVALID_REGION_MSG.formatted(region)); 24 | } 25 | 26 | @Test 27 | void testValidRegion(){ 28 | final String region = "us-ashburn-1"; 29 | StaticRegionProvider regionProvider = new StaticRegionProvider(region); 30 | 31 | assertNotNull(regionProvider.getRegion()); 32 | } 33 | 34 | @Test 35 | void testEmptyRegion(){ 36 | StaticRegionProvider regionProvider = new StaticRegionProvider(); 37 | 38 | assertNull(regionProvider.getRegion()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-core/src/test/java/com/oracle/cloud/spring/core/util/OCIObjectMapperTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.core.util; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Getter; 10 | import lombok.NoArgsConstructor; 11 | import lombok.ToString; 12 | import org.json.JSONException; 13 | import org.json.JSONObject; 14 | import org.junit.jupiter.api.Test; 15 | 16 | 17 | import static org.junit.jupiter.api.Assertions.*; 18 | 19 | class OCIObjectMapperTests { 20 | 21 | @Test 22 | void testObjectMapper() throws JSONException { 23 | TestJsonObject inputJson = new TestJsonObject(12, "fee", "foo"); 24 | String jsonToStr = OCIObjectMapper.toPrintableString(inputJson); 25 | JSONObject strToJson = new JSONObject(jsonToStr); 26 | 27 | assertEquals(strToJson.get("id"), inputJson.getId()); 28 | assertEquals(strToJson.getString("firstName"), inputJson.getFirstName()); 29 | assertEquals(strToJson.getString("lastName"), inputJson.getLastName()); 30 | } 31 | 32 | @Getter 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @ToString 36 | static final class TestJsonObject { 37 | private int id; 38 | private String firstName; 39 | private String lastName; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-email/src/main/java/com/oracle/cloud/spring/email/EmailDeliveryJavaMailSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | package com.oracle.cloud.spring.email; 6 | 7 | import java.io.InputStream; 8 | 9 | import jakarta.mail.MessagingException; 10 | import jakarta.mail.Session; 11 | import jakarta.mail.internet.MimeMessage; 12 | import org.springframework.mail.MailException; 13 | import org.springframework.mail.MailParseException; 14 | import org.springframework.mail.javamail.JavaMailSender; 15 | 16 | public class EmailDeliveryJavaMailSender extends EmailDeliveryMailSender implements JavaMailSender { 17 | public EmailDeliveryJavaMailSender(Session session, String smtpHost, String smtpUsername, String smtpPassword) { 18 | super(session, smtpHost, smtpUsername, smtpPassword); 19 | } 20 | 21 | @Override 22 | public MimeMessage createMimeMessage() { 23 | return new MimeMessage(session); 24 | } 25 | 26 | @Override 27 | public MimeMessage createMimeMessage(InputStream contentStream) throws MailException { 28 | try { 29 | return new MimeMessage(session, contentStream); 30 | } catch (MessagingException e) { 31 | throw new MailParseException(e); 32 | } 33 | } 34 | 35 | @Override 36 | public void send(MimeMessage... mimeMessages) throws MailException { 37 | for (MimeMessage mimeMessage : mimeMessages) { 38 | sendMimeMessage(mimeMessage); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-email/src/test/java/com/oracle/cloud/spring/email/EmailDeliveryJavaMailSenderTest.java: -------------------------------------------------------------------------------- 1 | package com.oracle.cloud.spring.email; 2 | 3 | import jakarta.mail.Message; 4 | import jakarta.mail.MessagingException; 5 | import jakarta.mail.internet.MimeMessage; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import static org.mockito.ArgumentMatchers.any; 9 | import static org.mockito.Mockito.times; 10 | import static org.mockito.Mockito.verify; 11 | 12 | public class EmailDeliveryJavaMailSenderTest extends EmailTest { 13 | @Test 14 | void sendMessage() throws MessagingException { 15 | EmailDeliveryJavaMailSender sender = getSender(); 16 | sender.send(getMimeMessage(sender)); 17 | verify(transport, times(1)).sendMessage(any(), any()); 18 | } 19 | 20 | @Test 21 | void sendMessages() throws MessagingException { 22 | EmailDeliveryJavaMailSender sender = getSender(); 23 | sender.send(getMimeMessage(sender), getMimeMessage(sender), getMimeMessage(sender)); 24 | verify(transport, times(3)).sendMessage(any(), any()); 25 | } 26 | 27 | private EmailDeliveryJavaMailSender getSender() { 28 | return new EmailDeliveryJavaMailSender(session, "x", "y", "z"); 29 | } 30 | 31 | private MimeMessage getMimeMessage(EmailDeliveryJavaMailSender sender) throws MessagingException { 32 | MimeMessage message = sender.createMimeMessage(); 33 | message.setFrom(testEmail); 34 | message.setRecipients(Message.RecipientType.TO, testEmail2); 35 | message.setText(testBody); 36 | message.setSubject(testSubject); 37 | return message; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-email/src/test/java/com/oracle/cloud/spring/email/EmailTest.java: -------------------------------------------------------------------------------- 1 | package com.oracle.cloud.spring.email; 2 | 3 | import java.util.Properties; 4 | 5 | import jakarta.mail.NoSuchProviderException; 6 | import jakarta.mail.Session; 7 | import jakarta.mail.Transport; 8 | import org.junit.jupiter.api.BeforeEach; 9 | 10 | import static org.mockito.Mockito.mock; 11 | import static org.mockito.Mockito.when; 12 | 13 | public class EmailTest { 14 | final String testEmail = "test@test.xyz"; 15 | final String testEmail2 = "test2@test.xyz"; 16 | final String testEmail3 = "test3@test.xyz"; 17 | final String testSubject = "test subject"; 18 | final String testBody = "test body"; 19 | Session session; 20 | Transport transport; 21 | 22 | @BeforeEach 23 | void setUpEach() throws NoSuchProviderException { 24 | session = mock(Session.class); 25 | transport = mock(Transport.class); 26 | when(session.getTransport()).thenReturn(transport); 27 | when(session.getProperties()).thenReturn(new Properties()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-function/src/main/java/com/oracle/cloud/spring/function/Function.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.function; 7 | 8 | import com.oracle.bmc.functions.FunctionsInvoke; 9 | import com.oracle.bmc.functions.requests.InvokeFunctionRequest; 10 | import com.oracle.bmc.functions.responses.InvokeFunctionResponse; 11 | 12 | import java.io.InputStream; 13 | 14 | /** 15 | * Interface for defining the OCI Function module. 16 | */ 17 | public interface Function { 18 | 19 | /** 20 | * Direct instance of OCI Function Invoke Client. 21 | * @return FunctionsInvoke 22 | */ 23 | FunctionsInvoke getFunctionsInvokeClient(); 24 | 25 | /** 26 | * Invoke an OCI Function 27 | * @param functionOcid OCID of the Function 28 | * @param endpoint Function endpoint 29 | * @param mode Function invocation mode. Allowed values are as per {@link InvokeFunctionRequest.FnInvokeType} 30 | * @param request Request body as String 31 | * @return InvokeFunctionResponse 32 | * 33 | */ 34 | InvokeFunctionResponse invokeFunction(String functionOcid, String endpoint, InvokeFunctionRequest.FnInvokeType mode, InputStream request) throws Exception; 35 | } 36 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-function/src/test/java/com/oracle/cloud/spring/function/FunctionImplTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.function; 7 | 8 | import com.oracle.bmc.functions.FunctionsInvokeClient; 9 | import com.oracle.bmc.functions.requests.InvokeFunctionRequest; 10 | import com.oracle.bmc.functions.responses.InvokeFunctionResponse; 11 | import org.junit.jupiter.api.Test; 12 | 13 | import java.io.ByteArrayInputStream; 14 | import java.nio.charset.StandardCharsets; 15 | 16 | import static org.junit.jupiter.api.Assertions.*; 17 | import static org.mockito.Mockito.*; 18 | 19 | class FunctionImplTests { 20 | 21 | final FunctionsInvokeClient fnInvokeClient = mock(FunctionsInvokeClient.class); 22 | final Function function = new FunctionImpl(fnInvokeClient); 23 | 24 | @Test 25 | void testFunctionClient() throws Exception { 26 | when(fnInvokeClient.invokeFunction(any())).thenReturn(mock(InvokeFunctionResponse.class)); 27 | assertNotNull(function.invokeFunction("fn_ocid", "fn_endpoint", 28 | InvokeFunctionRequest.FnInvokeType.Detached, 29 | new ByteArrayInputStream("fn_request".getBytes(StandardCharsets.UTF_8)))); 30 | assertNotNull(function.getFunctionsInvokeClient()); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-gen-ai/src/main/java/com/oracle/cloud/spring/genai/InferenceRequestType.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.genai; 7 | 8 | import lombok.Getter; 9 | 10 | /** 11 | * Supported OCI Inference model request types. 12 | */ 13 | @Getter 14 | public enum InferenceRequestType { 15 | COHERE("COHERE"), 16 | LLAMA("LLAMA"); 17 | 18 | private final String type; 19 | 20 | InferenceRequestType(String type) { 21 | this.type = type; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-logging/src/main/java/com/oracle/cloud/spring/logging/LogService.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.logging; 7 | 8 | import com.oracle.bmc.loggingingestion.Logging; 9 | import com.oracle.bmc.loggingingestion.responses.PutLogsResponse; 10 | 11 | /** 12 | * Interface for defining the OCI logging module. 13 | */ 14 | public interface LogService { 15 | 16 | /** 17 | * Direct instance of OCI Java SDK Logging Client. 18 | * @return Logging 19 | */ 20 | Logging getClient(); 21 | 22 | /** 23 | * Ingest logs associated with a Log OCID 24 | * @param logText Content of the log to be ingested 25 | * @return PutLogsResponse 26 | */ 27 | PutLogsResponse putLog(String logText); 28 | } 29 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-logging/src/test/java/com/oracle/cloud/spring/logging/LogServiceImplTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.logging; 7 | 8 | import com.oracle.bmc.loggingingestion.Logging; 9 | import com.oracle.bmc.loggingingestion.LoggingClient; 10 | import com.oracle.bmc.loggingingestion.responses.PutLogsResponse; 11 | import org.junit.jupiter.api.Test; 12 | 13 | import static org.junit.jupiter.api.Assertions.assertNotNull; 14 | import static org.junit.jupiter.api.Assertions.assertThrows; 15 | 16 | import static org.mockito.Mockito.*; 17 | 18 | class LogServiceImplTests { 19 | 20 | @Test 21 | void testLogServiceImplWithNullLogId() { 22 | assertThrows(IllegalArgumentException.class, ()-> { getLogService(null);}); 23 | } 24 | 25 | @Test 26 | void testLogServiceImplWithNonNullLogId() { 27 | LogService logService = getLogService("demoLogId"); 28 | assertNotNull(logService.getClient()); 29 | assertNotNull(logService.putLog("sample log")); 30 | } 31 | 32 | private LogService getLogService(String logId) { 33 | Logging logging = getMockedLogging(); 34 | PutLogsResponse response = mock(PutLogsResponse.class); 35 | when(logging.putLogs(any())).thenReturn(response); 36 | LogService logService = new LogServiceImpl(logging, logId); 37 | return logService; 38 | } 39 | 40 | private Logging getMockedLogging() { 41 | Logging logging = mock(LoggingClient.class); 42 | return logging; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/README.md: -------------------------------------------------------------------------------- 1 | # Spring Cloud Oracle - Samples 2 | 3 | The code samples in this directory demonstrate how to use the services supported by Spring Cloud Oracle. 4 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-adb-sample/src/main/java/com/oracle/cloud/spring/sample/adb/springcloudociadbsample/HelloController.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | package com.oracle.cloud.spring.sample.adb.springcloudociadbsample; 5 | 6 | import io.swagger.v3.oas.annotations.tags.Tag; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("demoapp/api") 13 | @Tag(name = "Hello World APIs") 14 | public class HelloController { 15 | @GetMapping("/") 16 | public String hello() { 17 | return "Hello World From Autonomus Database Service"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-adb-sample/src/main/java/com/oracle/cloud/spring/sample/adb/springcloudociadbsample/SpringCloudOciAdbSampleApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | 5 | package com.oracle.cloud.spring.sample.adb.springcloudociadbsample; 6 | 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | @SpringBootApplication 11 | public class SpringCloudOciAdbSampleApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringCloudOciAdbSampleApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-adb-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static = us-phoenix-1 5 | #spring.cloud.oci.config.type = RESOURCE_PRINCIPAL -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-common-samples-utils/src/main/java/com/oracle/cloud/spring/sample/common/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.common.util; 7 | 8 | import java.io.File; 9 | import java.io.FileWriter; 10 | 11 | public class FileUtils { 12 | 13 | /** 14 | * File Utility to help file operations like create and delete 15 | */ 16 | public static void createFile(String filePath, String fileContent) throws Exception { 17 | File file = new File(filePath); 18 | if(!file.exists() || file.isDirectory()) { 19 | String directoryPath = filePath.substring(0, filePath.lastIndexOf(File.separator)); 20 | File directory = new File(directoryPath); 21 | boolean bool = directory.mkdirs(); 22 | FileWriter myWriter = new FileWriter(filePath); 23 | myWriter.write(fileContent); 24 | myWriter.close(); 25 | } 26 | } 27 | 28 | public static boolean deleteFile(String filePath) { 29 | File f = new File(filePath); 30 | return f.delete(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-common-samples-utils/src/test/java/com/oracle/cloud/spring/sample/common/base/SpringCloudSampleApplicationTestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.common.base; 7 | 8 | 9 | 10 | import com.oracle.cloud.spring.sample.common.util.FileUtils; 11 | import org.junit.jupiter.api.AfterAll; 12 | import org.junit.jupiter.api.BeforeAll; 13 | 14 | import java.io.File; 15 | 16 | /** 17 | * Base class to be extended by Spring boot test classes 18 | */ 19 | 20 | public class SpringCloudSampleApplicationTestBase { 21 | 22 | static final String PRIVATE_KEY_PATH = "privateKey"; 23 | static final String PRIVATE_KEY_CONTENT = "privateKeyContent"; 24 | static final String privateKeyFilePath = System.getProperty("user.home") + File.separator + "privatekey.pem"; 25 | static final String privateKeyContent = System.getProperty(PRIVATE_KEY_CONTENT) != null ? System.getProperty(PRIVATE_KEY_CONTENT) : 26 | System.getenv().get(PRIVATE_KEY_CONTENT); 27 | @BeforeAll 28 | static void beforeAll() throws Exception { 29 | System.setProperty(PRIVATE_KEY_PATH, privateKeyFilePath); 30 | FileUtils.createFile(privateKeyFilePath, privateKeyContent.replace("\\n", "\n")); 31 | } 32 | 33 | @AfterAll 34 | static void AfterAll() { 35 | FileUtils.deleteFile(privateKeyFilePath); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-email-sample/src/main/java/com/oracle/cloud/spring/sample/email/springcloudemailsample/SpringCloudEmailSampleApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | package com.oracle.cloud.spring.sample.email.springcloudemailsample; 5 | 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | 9 | @SpringBootApplication 10 | public class SpringCloudEmailSampleApplication { 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringCloudEmailSampleApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-email-sample/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | mail: 3 | host: ${OCI_SMTP_HOST} 4 | username: ${OCI_SMTP_USERNAME} 5 | password: ${OCI_SMTP_PASSWORD} 6 | # Port 25 or 587 may be used. 7 | port: 587 -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-email-sample/src/test/java/com/oracle/cloud/spring/sample/email/springcloudemailsample/EmailIT.java: -------------------------------------------------------------------------------- 1 | package com.oracle.cloud.spring.sample.email.springcloudemailsample; 2 | 3 | import java.io.File; 4 | 5 | import org.junit.jupiter.api.Disabled; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | 11 | @SpringBootTest 12 | @EnabledIfEnvironmentVariable(named = "OCI_SMTP_HOST", matches = "+.") 13 | @EnabledIfEnvironmentVariable(named = "OCI_SMTP_USERNAME", matches = "+.") 14 | @EnabledIfEnvironmentVariable(named = "OCI_SMTP_PASSWORD", matches = "+.") 15 | @EnabledIfEnvironmentVariable(named = "OCI_FROM_ADDRESS", matches = "+.") 16 | public class EmailIT { 17 | @Autowired 18 | EmailService emailService; 19 | 20 | private final String address = System.getenv("OCI_FROM_ADDRESS"); 21 | 22 | @Test 23 | void sendJavaMail() throws Exception { 24 | File attachmentFile = new File("src/test/resources/attachment.txt"); 25 | emailService.sendJavaMail( 26 | address, 27 | address, 28 | "Java Mail Test", 29 | "This is a test of the EmailDeliveryJavaMailSender Bean", 30 | attachmentFile 31 | ); 32 | } 33 | 34 | @Test 35 | @Disabled 36 | void sendSimpleMail() { 37 | emailService.sendSimpleMail( 38 | address, 39 | address, 40 | "Simple Email Test", 41 | "This is a test of the EmailDeliveryMailSender Bean" 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-email-sample/src/test/resources/attachment.txt: -------------------------------------------------------------------------------- 1 | This is a test attachment. -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-function-sample/src/main/java/com/oracle/cloud/spring/sample/function/springcloudocifunctionsample/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.function.springcloudocifunctionsample; 7 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("demoapp/api") 15 | @Tag(name="Hello World APIs") 16 | public class HelloController { 17 | 18 | @GetMapping("/") 19 | public String hello() { 20 | return "Hello World From Function Service"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-function-sample/src/main/java/com/oracle/cloud/spring/sample/function/springcloudocifunctionsample/SpringCloudOciFunctionSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.function.springcloudocifunctionsample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciFunctionSampleApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringCloudOciFunctionSampleApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-function-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static = us-ashburn-1 5 | #spring.cloud.oci.config.type = SESSION_TOKEN 6 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-function-sample/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.oci.config.type = SIMPLE 2 | spring.cloud.oci.config.userId = ${userId} 3 | spring.cloud.oci.config.tenantId = ${tenantId} 4 | spring.cloud.oci.config.fingerprint = ${fingerprint} 5 | spring.cloud.oci.config.privateKey = ${privateKey} 6 | spring.cloud.oci.config.region = ${region} 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/main/java/com/oracle/cloud/spring/sample/genai/springcloudocigenaisample/SpringCloudOciGenAISampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.genai.springcloudocigenaisample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciGenAISampleApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringCloudOciGenAISampleApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static=us-chicago-1 5 | spring.cloud.oci.config.type=file 6 | 7 | spring.cloud.oci.genai.chat.enabled=true 8 | spring.cloud.oci.genai.embedding.enabled=true 9 | 10 | spring.cloud.oci.genai.embedding.compartment=${OCI_COMPARTMENT_ID} 11 | spring.cloud.oci.genai.chat.compartment=${OCI_COMPARTMENT_ID} 12 | 13 | spring.cloud.oci.genai.chat.onDemandModelId=${OCI_CHAT_MODEL_ID} 14 | spring.cloud.oci.genai.embedding.onDemandModelId=${OCI_EMBEDDING_MODEL_ID} 15 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/java/com/oracle/cloud/spring/sample/genai/springcloudocigenaisample/ChatIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.genai.springcloudocigenaisample; 7 | 8 | import com.oracle.bmc.generativeaiinference.responses.ChatResponse; 9 | import com.oracle.cloud.spring.genai.ChatModel; 10 | 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | 13 | public class ChatIT { 14 | public void chat(ChatModel chatModel) { 15 | ChatResponse r1 = chatModel.chat("Show me an example of a JUnit 5 test."); 16 | String text1 = chatModel.extractText(r1); 17 | assertThat(text1).contains("@Test"); 18 | ChatResponse r2 = chatModel.chat("Add a test to the previous example named 'sampleTest'"); 19 | String text2 = chatModel.extractText(r2); 20 | assertThat(text2).contains("sampleTest"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/java/com/oracle/cloud/spring/sample/genai/springcloudocigenaisample/CohereChatIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.genai.springcloudocigenaisample; 7 | 8 | import com.oracle.cloud.spring.genai.ChatModel; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.ActiveProfiles; 14 | 15 | @SpringBootTest 16 | @EnabledIfEnvironmentVariable(named = "OCI_COMPARTMENT_ID", matches = ".+") 17 | @EnabledIfEnvironmentVariable(named = "OCI_COHERE_MODEL_ID", matches = ".+") 18 | @ActiveProfiles("chat-cohere") 19 | public class CohereChatIT extends ChatIT { 20 | @Autowired 21 | ChatModel chatModel; 22 | 23 | @Test 24 | public void chat() { 25 | super.chat(chatModel); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/java/com/oracle/cloud/spring/sample/genai/springcloudocigenaisample/EmbeddingIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.genai.springcloudocigenaisample; 7 | 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | import java.util.stream.IntStream; 11 | 12 | import com.oracle.bmc.generativeaiinference.responses.EmbedTextResponse; 13 | import com.oracle.cloud.spring.genai.EmbeddingModel; 14 | import org.junit.jupiter.api.Assertions; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | import org.springframework.test.context.ActiveProfiles; 20 | 21 | @SpringBootTest 22 | @EnabledIfEnvironmentVariable(named = "OCI_COMPARTMENT_ID", matches = ".+") 23 | @ActiveProfiles("embedding") 24 | public class EmbeddingIT { 25 | @Autowired 26 | EmbeddingModel embeddingModel; 27 | 28 | @Test 29 | public void embed() { 30 | EmbedTextResponse response = embeddingModel.embed("The USA has 50 states."); 31 | List> embeddings = embeddingModel.fromResponse(response); 32 | Assertions.assertEquals(1, embeddings.size()); 33 | } 34 | 35 | @Test 36 | public void embedAll() { 37 | List responses = embeddingModel.embedAll(IntStream.range(0, 3).mapToObj(i -> String.format("embedding %d", i)).collect(Collectors.toList())); 38 | List> embeddings = embeddingModel.fromResponses(responses); 39 | Assertions.assertEquals(3, embeddings.size()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/java/com/oracle/cloud/spring/sample/genai/springcloudocigenaisample/LLamaChatIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.genai.springcloudocigenaisample; 7 | 8 | import com.oracle.cloud.spring.genai.ChatModel; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.ActiveProfiles; 14 | 15 | @SpringBootTest 16 | @EnabledIfEnvironmentVariable(named = "OCI_COMPARTMENT_ID", matches = ".+") 17 | @EnabledIfEnvironmentVariable(named = "OCI_LLAMA_MODEL_ID", matches = ".+") 18 | @ActiveProfiles("chat-llama") 19 | public class LLamaChatIT extends ChatIT { 20 | @Autowired 21 | ChatModel chatModel; 22 | 23 | @Test 24 | public void chat() { 25 | super.chat(chatModel); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/resources/application-chat-cohere.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.genai.chat.on-demand-model-id=${OCI_COHERE_MODEL_ID} 5 | spring.cloud.oci.genai.chat.inference-request-type=cohere 6 | spring.cloud.oci.genai.embedding.enabled=false 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/resources/application-chat-llama.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.genai.chat.on-demand-model-id=${OCI_LLAMA_MODEL_ID} 5 | spring.cloud.oci.genai.chat.inference-request-type=llama 6 | spring.cloud.oci.genai.embedding.enabled=false 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-gen-ai-sample/src/test/resources/application-embedding.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.genai.embedding.on-demand-model-id=cohere.embed-english-light-v2.0 5 | spring.cloud.oci.genai.chat.enabled=false 6 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-logging-sample/src/main/java/com/oracle/cloud/spring/sample/logging/springcloudociloggingsample/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.logging.springcloudociloggingsample; 7 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("demoapp/api") 15 | @Tag(name="Hello World APIs") 16 | public class HelloController { 17 | 18 | @GetMapping("/") 19 | public String hello() { 20 | return "Hello World From logging Service"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-logging-sample/src/main/java/com/oracle/cloud/spring/sample/logging/springcloudociloggingsample/LoggingController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.logging.springcloudociloggingsample; 7 | 8 | import com.oracle.bmc.loggingingestion.responses.PutLogsResponse; 9 | import com.oracle.cloud.spring.logging.LogService; 10 | import io.swagger.v3.oas.annotations.Parameter; 11 | import io.swagger.v3.oas.annotations.tags.Tag; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.http.ResponseEntity; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | @RestController 20 | @RequestMapping("/demoapp/api/logging/") 21 | @Tag(name = "logging APIs") 22 | public class LoggingController { 23 | 24 | @Autowired 25 | LogService logService; 26 | 27 | @PostMapping(value = "putlog") 28 | ResponseEntity putLog(@Parameter(required = true, example = "logText") @RequestParam String logText) { 29 | PutLogsResponse response = logService.putLog(logText); 30 | return ResponseEntity.ok().body("opc request Id for posting the logs : " + response.getOpcRequestId()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-logging-sample/src/main/java/com/oracle/cloud/spring/sample/logging/springcloudociloggingsample/SpringCloudOciLoggingSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.logging.springcloudociloggingsample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciLoggingSampleApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringCloudOciLoggingSampleApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-logging-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static = us-ashburn-1 5 | 6 | spring.cloud.oci.logging.logId = 7 | #spring.cloud.oci.config.type = RESOURCE_PRINCIPAL 8 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-logging-sample/src/test/java/com/oracle/cloud/spring/sample/logging/springcloudociloggingsample/SpringCloudOciLoggingSampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.logging.springcloudociloggingsample; 7 | 8 | import com.oracle.bmc.loggingingestion.responses.PutLogsResponse; 9 | 10 | import com.oracle.cloud.spring.logging.LogService; 11 | import com.oracle.cloud.spring.sample.common.base.SpringCloudSampleApplicationTestBase; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.test.context.SpringBootTest; 16 | import org.springframework.test.context.TestPropertySource; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertNotNull; 19 | 20 | 21 | /** 22 | * Environment variables needed to run this tests are : 23 | * all variables in application-test.properties files 24 | */ 25 | 26 | @SpringBootTest 27 | @EnabledIfSystemProperty(named = "it.logging", matches = "true") 28 | @TestPropertySource(locations="classpath:application-test.properties") 29 | class SpringCloudOciLoggingSampleApplicationTests extends SpringCloudSampleApplicationTestBase { 30 | @Autowired 31 | LogService logService; 32 | 33 | @Test 34 | void testLogMessage() { 35 | PutLogsResponse response = logService.putLog("error starting logging application"); 36 | assertNotNull(response.getOpcRequestId()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-logging-sample/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.oci.config.type = SIMPLE 2 | spring.cloud.oci.config.userId = ${userId} 3 | spring.cloud.oci.config.tenantId = ${tenantId} 4 | spring.cloud.oci.config.fingerprint = ${fingerprint} 5 | spring.cloud.oci.config.privateKey = ${privateKey} 6 | spring.cloud.oci.config.region = ${region} 7 | 8 | 9 | spring.cloud.oci.logging.log-id = ${logId} -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-nosql-sample/src/main/java/com/oracle/cloud/spring/sample/nosql/springcloudnosqlsample/BookRepository.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.sample.nosql.springcloudnosqlsample; 4 | 5 | import com.oracle.nosql.spring.data.repository.NosqlRepository; 6 | 7 | public interface BookRepository extends NosqlRepository { 8 | Iterable findByAuthor(String author); 9 | Iterable findByTitle(String title); 10 | } -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-nosql-sample/src/main/java/com/oracle/cloud/spring/sample/nosql/springcloudnosqlsample/SpringCloudOciNoSQLSampleApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.sample.nosql.springcloudnosqlsample; 4 | 5 | import com.oracle.nosql.spring.data.config.AbstractNosqlConfiguration; 6 | import com.oracle.nosql.spring.data.repository.config.EnableNosqlRepositories; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | @SpringBootApplication 11 | @EnableNosqlRepositories 12 | public class SpringCloudOciNoSQLSampleApplication extends AbstractNosqlConfiguration { 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringCloudOciNoSQLSampleApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-nosql-sample/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | oci: 4 | config: 5 | type: file 6 | region: 7 | static: us-ashburn-1 8 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-notification-sample/src/main/java/com/oracle/cloud/spring/sample/notification/springcloudocinotificationsample/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.notification.springcloudocinotificationsample; 7 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("demoapp/api") 15 | @Tag(name="Hello World APIs") 16 | public class HelloController { 17 | 18 | @GetMapping("/") 19 | public String hello() { 20 | return "Hello World From Notification Service"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-notification-sample/src/main/java/com/oracle/cloud/spring/sample/notification/springcloudocinotificationsample/SpringCloudOciNotificationSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.notification.springcloudocinotificationsample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciNotificationSampleApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringCloudOciNotificationSampleApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-notification-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static = us-ashburn-1 5 | #spring.cloud.oci.config.type = RESOURCE_PRINCIPAL 6 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-notification-sample/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.oci.config.type = SIMPLE 2 | spring.cloud.oci.config.userId = ${userId} 3 | spring.cloud.oci.config.tenantId = ${tenantId} 4 | spring.cloud.oci.config.fingerprint = ${fingerprint} 5 | spring.cloud.oci.config.privateKey = ${privateKey} 6 | spring.cloud.oci.config.region = ${region} 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-queue-sample/src/main/java/com/oracle/cloud/spring/sample/queue/springcloudociqueuesample/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.queue.springcloudociqueuesample; 7 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("demoapp/api") 15 | @Tag(name = "Hello World APIs") 16 | public class HelloController { 17 | @GetMapping("/") 18 | public String hello() { 19 | return "Hello World From Queue Service"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-queue-sample/src/main/java/com/oracle/cloud/spring/sample/queue/springcloudociqueuesample/SpringCloudOciQueueSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.queue.springcloudociqueuesample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciQueueSampleApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringCloudOciQueueSampleApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-queue-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static = us-ashburn-1 5 | #spring.cloud.oci.config.type = RESOURCE_PRINCIPAL 6 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-queue-sample/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.oci.config.type = SIMPLE 2 | spring.cloud.oci.config.userId = ${userId} 3 | spring.cloud.oci.config.tenantId = ${tenantId} 4 | spring.cloud.oci.config.fingerprint = ${fingerprint} 5 | spring.cloud.oci.config.privateKey = ${privateKey} 6 | spring.cloud.oci.config.region = ${region} 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-storage-sample/images/swagger-ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/spring-cloud-oracle/b3bdce9878f71d1676fc05f4d41b4d440fc84a20/spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-storage-sample/images/swagger-ui.png -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-storage-sample/src/main/java/com/oracle/cloud/spring/sample/storage/springcloudocistoragesample/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.storage.springcloudocistoragesample; 7 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.io.IOException; 14 | 15 | @RestController 16 | @RequestMapping("demoapp/api") 17 | @Tag(name="Hello World APIs") 18 | public class HelloController { 19 | 20 | @GetMapping("/") 21 | public String hello() throws IOException { 22 | return "Hello World "; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-storage-sample/src/main/java/com/oracle/cloud/spring/sample/storage/springcloudocistoragesample/SpringCloudOciStorageSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.storage.springcloudocistoragesample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciStorageSampleApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringCloudOciStorageSampleApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-storage-sample/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | oci: 4 | compartment: 5 | static: ${OCI_COMPARTMENT} 6 | config: 7 | type: file 8 | region: 9 | static: us-chicago-1 10 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-streaming-sample/src/main/java/com/oracle/cloud/spring/sample/streaming/springcloudocistreamingsample/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.streaming.springcloudocistreamingsample; 7 | 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("demoapp/api") 15 | @Tag(name="Hello World APIs") 16 | public class HelloController { 17 | 18 | @GetMapping("/") 19 | public String hello() { 20 | return "Hello World From Stream Service"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-streaming-sample/src/main/java/com/oracle/cloud/spring/sample/streaming/springcloudocistreamingsample/SpringCloudOciStreamingSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.sample.streaming.springcloudocistreamingsample; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | @SpringBootApplication 12 | public class SpringCloudOciStreamingSampleApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringCloudOciStreamingSampleApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-streaming-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | 4 | spring.cloud.oci.region.static = us-ashburn-1 5 | 6 | #spring.cloud.oci.config.type = RESOURCE_PRINCIPAL 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-streaming-sample/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.oci.config.type = SIMPLE 2 | spring.cloud.oci.config.userId = ${userId} 3 | spring.cloud.oci.config.tenantId = ${tenantId} 4 | spring.cloud.oci.config.fingerprint = ${fingerprint} 5 | spring.cloud.oci.config.privateKey = ${privateKey} 6 | spring.cloud.oci.config.region = ${region} 7 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-vault-sample/src/main/java/com/oracle/cloud/spring/sample/vault/springcloudocivaultsample/SpringCloudOciVaultSampleApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.sample.vault.springcloudocivaultsample; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | public class SpringCloudOciVaultSampleApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(SpringCloudOciVaultSampleApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-vault-sample/src/main/java/com/oracle/cloud/spring/sample/vault/springcloudocivaultsample/VaultController.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Oracle and/or its affiliates. 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 3 | package com.oracle.cloud.spring.sample.vault.springcloudocivaultsample; 4 | 5 | import com.oracle.bmc.secrets.responses.GetSecretBundleByNameResponse; 6 | import com.oracle.cloud.spring.vault.VaultTemplate; 7 | import io.swagger.v3.oas.annotations.tags.Tag; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | @RestController 16 | @RequestMapping("/demoapp/api/vault/") 17 | @Tag(name = "Vault APIs") 18 | public class VaultController { 19 | // This value will be loaded from OCI Vault 20 | @Value("${mysecret}") 21 | private String vaultSecretValue; 22 | 23 | private final VaultTemplate vaultTemplate; 24 | 25 | public VaultController(VaultTemplate vaultTemplate) { 26 | this.vaultTemplate = vaultTemplate; 27 | } 28 | 29 | @GetMapping("secret") 30 | public ResponseEntity getSecret(@RequestParam String secretName) { 31 | GetSecretBundleByNameResponse secret = vaultTemplate.getSecret(secretName); 32 | return ResponseEntity.ok(vaultTemplate.decodeBundle(secret)); 33 | } 34 | 35 | public String getVaultSecretValue() { 36 | return vaultSecretValue; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-samples/spring-cloud-oci-vault-sample/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | oci: 4 | config: 5 | type: file 6 | region: 7 | static: us-chicago-1 8 | vault: 9 | compartment: ${OCI_COMPARTMENT_ID} 10 | vault-id: ${OCI_VAULT_ID} 11 | enabled: true 12 | property-refresh-interval: 10000ms 13 | property-sources: 14 | - vault-id: ${OCI_VAULT_ID} -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-storage/src/main/java/com/oracle/cloud/spring/storage/StorageContentTypeResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.storage; 7 | 8 | import org.springframework.lang.Nullable; 9 | 10 | /** 11 | * Content Type resolver based on file name. 12 | */ 13 | public interface StorageContentTypeResolver { 14 | 15 | @Nullable 16 | String resolveContentType(String fileName); 17 | } 18 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-storage/src/main/java/com/oracle/cloud/spring/storage/StorageException.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.storage; 7 | 8 | import org.springframework.lang.Nullable; 9 | 10 | /** 11 | * Exception thrown from any OCI storage-related API invocation failures. 12 | */ 13 | public class StorageException extends RuntimeException { 14 | 15 | public StorageException(String message, @Nullable Throwable cause) { 16 | super(message, cause); 17 | } 18 | } -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-storage/src/main/java/com/oracle/cloud/spring/storage/StorageObjectConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.storage; 7 | 8 | import java.io.InputStream; 9 | 10 | /** 11 | * Interface to convert Java POJOs to byte array stored on OCI storage service and InputStream of an object to Java POJO. 12 | */ 13 | public interface StorageObjectConverter { 14 | /** 15 | * Converts a Java POJO to byte array. 16 | * @param object Java POJO 17 | * @param Type of the Java POJO 18 | * @return byte[] 19 | */ 20 | byte[] write(T object); 21 | 22 | /** 23 | * Reads InputStream and creates a Java POJO instance of the class T. 24 | * @param is InputStream to read data from. 25 | * @param clazz Class instance of the type of Java POJO 26 | * @param Type of the Java POJO 27 | * @return Instance of Java POJO 28 | */ 29 | T read(InputStream is, Class clazz); 30 | 31 | /** 32 | * Returns the storage content type. 33 | * @return String 34 | */ 35 | String contentType(); 36 | } 37 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-storage/src/test/java/com/oracle/cloud/spring/storage/OracleStorageProtocolResolverTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.storage; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.mockito.MockedStatic; 10 | import org.springframework.beans.factory.BeanFactory; 11 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 12 | import org.springframework.core.io.DefaultResourceLoader; 13 | 14 | import static org.mockito.Mockito.mock; 15 | import static org.mockito.Mockito.mockStatic; 16 | 17 | public class OracleStorageProtocolResolverTests { 18 | final BeanFactory beanFactory = mock(ConfigurableListableBeanFactory.class); 19 | final OracleStorageProtocolResolver oracleStorageProtocolResolver = new OracleStorageProtocolResolver(); 20 | 21 | @Test 22 | public void testPostProcessBeanFactory() { 23 | oracleStorageProtocolResolver.postProcessBeanFactory((ConfigurableListableBeanFactory) beanFactory); 24 | } 25 | 26 | @Test 27 | public void testSetResourceLoader() { 28 | oracleStorageProtocolResolver.setResourceLoader(new DefaultResourceLoader()); 29 | } 30 | 31 | @Test 32 | public void testGetStorageClient() { 33 | oracleStorageProtocolResolver.getStorageClient(); 34 | } 35 | 36 | @Test 37 | public void testResolve() { 38 | try (MockedStatic mock = mockStatic(OracleStorageResource.class)) { 39 | oracleStorageProtocolResolver.resolve("https://objectstorage.us-chicago-1.oraclecloud.com/n/namespace/b/mybucket/o/myobject", new DefaultResourceLoader()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-storage/src/test/java/com/oracle/cloud/spring/storage/StorageContentTypeResolverTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.storage; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | import static org.junit.jupiter.api.Assertions.assertThrows; 12 | 13 | import java.util.Properties; 14 | 15 | public class StorageContentTypeResolverTests { 16 | 17 | final StorageContentTypeResolver storageContentTypeResolver = new StorageContentTypeResolverImpl(); 18 | 19 | @Test 20 | public void testStorageContentTypeResolverImplWithNullProps() { 21 | Exception exception = assertThrows(IllegalArgumentException.class, () -> { 22 | new StorageContentTypeResolverImpl(null); 23 | }); 24 | assertEquals(StorageContentTypeResolverImpl.ERROR_PROPS_FILE_REQUIRED, exception.getMessage()); 25 | } 26 | 27 | @Test 28 | public void testResolveContentType() { 29 | Exception exception = assertThrows(IllegalArgumentException.class, () -> { 30 | storageContentTypeResolver.resolveContentType(null); 31 | }); 32 | assertEquals(StorageContentTypeResolverImpl.ERROR_FILE_NAME_REQUIRED, exception.getMessage()); 33 | 34 | storageContentTypeResolver.resolveContentType(".msi"); 35 | 36 | new StorageContentTypeResolverImpl(new Properties()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-cloud-oci/spring-cloud-oci-storage/src/test/java/com/oracle/cloud/spring/storage/StorageExceptionTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023, Oracle and/or its affiliates. 3 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ 4 | */ 5 | 6 | package com.oracle.cloud.spring.storage; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import static org.junit.jupiter.api.Assertions.*; 11 | 12 | public class StorageExceptionTests { 13 | @Test 14 | public void testException() { 15 | Exception exception = new StorageException("custom exception", new RuntimeException()); 16 | assertEquals("custom exception", exception.getMessage()); 17 | } 18 | } 19 | --------------------------------------------------------------------------------