- Temporarily remove dependency on Chile

- Simple persistence interface
This commit is contained in:
Konstantin Krivopustov 2008-10-31 15:06:24 +00:00
parent 514929c71b
commit a1f488653c
7 changed files with 108 additions and 15 deletions

View File

@ -277,13 +277,9 @@
<component name="WebServicesPlugin" addRequiredLibraries="true" /> <component name="WebServicesPlugin" addRequiredLibraries="true" />
<component name="libraryTable"> <component name="libraryTable">
<library name="chile"> <library name="chile">
<CLASSES> <CLASSES />
<root url="jar://$PROJECT_DIR$/../chile/build/chile-core.jar!/" />
</CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES />
<root url="file://$PROJECT_DIR$/../chile/modules/core/src" />
</SOURCES>
</library> </library>
<library name="server"> <library name="server">
<CLASSES> <CLASSES>

View File

@ -6,25 +6,25 @@
<property name="root.dir" location="${project.dir}/.."/> <property name="root.dir" location="${project.dir}/.."/>
<property name="module.name" value="core"/> <property name="module.name" value="core"/>
<property name="module.jar" value="cuba-core.jar"/> <property name="module.jar" value="20-cuba-core.jar"/>
<import file="${root.dir}/build-inc.xml"/> <import file="${root.dir}/build-inc.xml"/>
<property file="${root.dir}/build.properties"/> <property file="${root.dir}/build.properties"/>
<fileset id="chile-jars" dir="${root.dir}/chile/build">
<include name="*.jar"/>
</fileset>
<path id="compile-cp"> <path id="compile-cp">
<fileset refid="common-lib-fs"/> <fileset refid="common-lib-fs"/>
<fileset refid="server-lib-fs"/> <fileset refid="server-lib-fs"/>
<fileset dir="${root.dir}/chile/build"> <!--<fileset refid="chile-jars"/>-->
<include name="*.jar"/>
</fileset>
</path> </path>
<path id="test-compile-cp"> <path id="test-compile-cp">
<fileset refid="common-lib-fs"/> <fileset refid="common-lib-fs"/>
<fileset refid="server-lib-fs"/> <fileset refid="server-lib-fs"/>
<fileset dir="${root.dir}/chile/build"> <!--<fileset refid="chile-jars"/>-->
<include name="*.jar"/>
</fileset>
</path> </path>
</project> </project>

View File

@ -0,0 +1,14 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 31.10.2008 16:51:51
* $Id$
*/
package com.haulmont.cuba.core;
public interface BaseEntity
{
}

View File

@ -4,13 +4,13 @@
*/ */
package com.haulmont.cuba.core; package com.haulmont.cuba.core;
import com.haulmont.chile.core.ChileCore; //import com.haulmont.chile.core.ChileCore;
public class CubaCore { public class CubaCore {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello from CubaCore"); System.out.println("Hello from CubaCore");
new ChileCore(); // new ChileCore();
} }
public String getName() { public String getName() {

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 31.10.2008 16:56:32
* $Id$
*/
package com.haulmont.cuba.core;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
public class CubaEntityManager
{
private OpenJPAEntityManager jpaEm;
CubaEntityManager(OpenJPAEntityManager jpaEntityManager) {
this.jpaEm = jpaEntityManager;
}
public void insert(BaseEntity entity) {
jpaEm.persist(entity);
}
public <T> T merge(BaseEntity entity) {
return (T) jpaEm.merge(entity);
}
public void delete(BaseEntity entity) {
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 31.10.2008 16:55:55
* $Id$
*/
package com.haulmont.cuba.core;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
public class CubaEntityManagerFactory
{
private OpenJPAEntityManagerFactory jpaFactory;
public CubaEntityManagerFactory(OpenJPAEntityManagerFactory jpaFactory) {
this.jpaFactory = jpaFactory;
}
public CubaEntityManager getEntityManager() {
OpenJPAEntityManager em = jpaFactory.createEntityManager();
return new CubaEntityManager(em);
}
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 31.10.2008 17:58:40
* $Id$
*/
package com.haulmont.cuba.core;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
import org.apache.openjpa.persistence.OpenJPAPersistence;
public class ServiceLocator
{
public static CubaEntityManagerFactory getEntityManagerFactory() {
OpenJPAEntityManagerFactory jpaFactory =
OpenJPAPersistence.createEntityManagerFactory("cuba", "META-INF/cuba-persistence.xml");
return new CubaEntityManagerFactory(jpaFactory);
}
}