VMware's Cloudfoundry service obtains support for PostgreSQL

Source: Internet
Author: User
Keywords Name manager xml
Tags added application applications automatic class cloud cloud services http

Earlier this year, VMware announced the Cloudfoundry project, a platform, a service (PAAS) Open source solution, which provides support for MongoDB, MySQL, and redis such services. It recently added PostgreSQL and RABBITMQ to the cloud services list for use in all applications, as well as a micro version of Cloudfoundry that can run on a single workstation.

It is also interesting to include PostgreSQL in Cloudfoundry because it is a very distinctive traditional database with a different audience than MySQL or MongoDB users. In order to better use the postgresql,cloudfoundry and not directly use its normal release version, but a version of the vfabric on top of the custom, which is explained on the official blog. (Translator note: The Cloud platform for the PostgreSQL to do some optimization.) )

This blog gives a sample of how to use the spring Roo to work with PostgreSQL in a Java project. Here is another alternative scenario for Java applications that are a war that uses JPA based on spring.

Suppose your application has an existing spring context initialization content such as:

<bean id= "Entitymanagerfactory" class= "Org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" > <property name= "persistenceunitname" value= "Myjpamanager"/> <property name= "DataSource" DataSource "/></bean><bean class=" Org.springframework.jdbc.datasource.DriverManagerDataSource "id=" DataSource "> <property name=" driverclassname "value=" Org.postgresql.Driver "/> <property" url "value = "Jdbc:postgresql://localhost/postgres"/> <property name= "username" value= "postgres"/> <property "name=" Password "value=" Postgres "/></bean><bean id=" TransactionManager "class=" Org.springframework.orm.jpa.JpaTransactionManager "> <property name=" entitymanagerfactory "ref=" Entitymanagerfactory "/></bean><tx:annotation-driven transaction-manager=" TransactionManager "/> <context:annotation-config/>

and meta-inf/persistence.xml files such as:

<persistence xmlns= "http://java.sun.com/xml/ns/persistence" xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "xsi:schemalocation=" Http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/ Persistence/persistence_1_0.xsd "version=" 1.0 "> <persistence-unit name=" Myjpamanager "transaction-type=" Resource_local "> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name= "Hibernate.dialect" value= "Org.hibernate.dialect.PostgreSQLDialect"/> <property name= " Hibernate.hbm2ddl.auto "value=" update/> </properties> </persistence-unit></persistence>

Thanks to the Cloudfoundry automatic configuration feature, this application can be uploaded directly to the Cloudfoundry without any modification at all.

PostgreSQL (including MySQL and other platform-supported services) leverages the automatic provisioning capabilities provided by Cloudfoundry. Under certain conditions, a local Java application using PostgreSQL can be uploaded to the cloudfoundry without modifying any line of code.

Automatic configuration takes advantage of the functionality of the spring core container, and can take effect when the following two conditions are met:

Any given service type has and has only one service implementation. For example, you should only bind a relational database service (MySQL or PostgreSQL) to your application. Each matching type should have and have only one bean. For example, there should be only one data source bean in your application context.

If the above requirements are met, the Cloudfoundry will automatically intercept your local data source and use the Cloudfoundry service instead of the values set in the spring context.

The only thing left to do is to respond positively when the application is uploaded to the cloud, when the VMC requests the service to bind.

For more complex applications, Spring 3.1 is expected to add a special cloud namespace and provide Run-time profile support.

(Responsible editor: The good of the Legacy)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.