mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 18:27:56 +08:00
- Renamed to EntityManagerAdapter, EntityManagerFactoryAdapter
- Testing framework (1st iteration)
This commit is contained in:
parent
7e25ba1aab
commit
2fac72e270
@ -24,11 +24,15 @@
|
|||||||
<!-- jboss -->
|
<!-- jboss -->
|
||||||
<ext:install-jboss version="${jboss.version}" toDir="${jboss.dir}"/>
|
<ext:install-jboss version="${jboss.version}" toDir="${jboss.dir}"/>
|
||||||
<!-- libs -->
|
<!-- libs -->
|
||||||
|
<ext:install-lib name="junit" version="${junit.version}" toDir="${lib.test.dir}"/>
|
||||||
|
<ext:install-lib name="jboss-ejb3-embeddable" version="${jboss-ejb3-embeddable.version}" toDir="${lib.test.dir}"/>
|
||||||
|
<ext:install-lib name="jboss-ejb3-embeddable-thirdparty" version="${jboss-ejb3-embeddable-thirdparty.version}" toDir="${lib.test.dir}"/>
|
||||||
<ext:install-lib name="commons-lang" version="${commons-lang.version}" toDir="${lib.common.dir}"/>
|
<ext:install-lib name="commons-lang" version="${commons-lang.version}" toDir="${lib.common.dir}"/>
|
||||||
<ext:install-lib name="openjpa" version="${openjpa.version}" toDir="${lib.server.dir}"/>
|
<ext:install-lib name="openjpa" version="${openjpa.version}" toDir="${lib.server.dir}"/>
|
||||||
<ext:install-lib name="serp" version="${serp.version}" toDir="${lib.server.dir}"/>
|
<ext:install-lib name="serp" version="${serp.version}" toDir="${lib.server.dir}"/>
|
||||||
<ext:install-jboss-lib name="commons-logging" version="${jboss.version}" toDir="${lib.common.dir}"/>
|
<ext:install-jboss-lib name="commons-logging" version="${jboss.version}" toDir="${lib.common.dir}"/>
|
||||||
<ext:install-jboss-lib name="commons-collections" version="${jboss.version}" toDir="${lib.server.dir}"/>
|
<ext:install-jboss-lib name="commons-collections" version="${jboss.version}" toDir="${lib.server.dir}"/>
|
||||||
|
<ext:install-jboss-lib name="jboss-common" path="lib" version="${jboss-common.version}" toDir="${lib.server.dir}"/>
|
||||||
<ext:install-jboss-lib name="jboss" version="${jboss.version}" toDir="${lib.server.dir}"/>
|
<ext:install-jboss-lib name="jboss" version="${jboss.version}" toDir="${lib.server.dir}"/>
|
||||||
<ext:install-jboss-lib name="ejb3-persistence" version="${jboss.version}" toDir="${lib.common.dir}"/>
|
<ext:install-jboss-lib name="ejb3-persistence" version="${jboss.version}" toDir="${lib.common.dir}"/>
|
||||||
<ext:install-jboss-lib name="jboss-j2ee" version="${jboss.version}" toDir="${lib.server.dir}"/>
|
<ext:install-jboss-lib name="jboss-j2ee" version="${jboss.version}" toDir="${lib.server.dir}"/>
|
||||||
|
21
cuba.ipr
21
cuba.ipr
@ -77,6 +77,15 @@
|
|||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<entry_points version="2.0" />
|
<entry_points version="2.0" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="FacetAutodetectingManager">
|
||||||
|
<autodetection-disabled>
|
||||||
|
<facet-type id="jpa">
|
||||||
|
<modules>
|
||||||
|
<module name="core" />
|
||||||
|
</modules>
|
||||||
|
</facet-type>
|
||||||
|
</autodetection-disabled>
|
||||||
|
</component>
|
||||||
<component name="IdProvider" IDEtalkID="99EE4594F0AAAC224547C8FE93321E41" />
|
<component name="IdProvider" IDEtalkID="99EE4594F0AAAC224547C8FE93321E41" />
|
||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||||
@ -288,6 +297,7 @@
|
|||||||
<root url="jar://$PROJECT_DIR$/../lib/server/jboss.jar!/" />
|
<root url="jar://$PROJECT_DIR$/../lib/server/jboss.jar!/" />
|
||||||
<root url="jar://$PROJECT_DIR$/../lib/server/jboss-j2ee.jar!/" />
|
<root url="jar://$PROJECT_DIR$/../lib/server/jboss-j2ee.jar!/" />
|
||||||
<root url="jar://$PROJECT_DIR$/../lib/server/jboss-ejb3x.jar!/" />
|
<root url="jar://$PROJECT_DIR$/../lib/server/jboss-ejb3x.jar!/" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/../lib/server/serp-1.13.1.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
@ -305,6 +315,17 @@
|
|||||||
<root url="jar://$PROJECT_DIR$/../lib/common/src/commons-lang-2.4-src.zip!/" />
|
<root url="jar://$PROJECT_DIR$/../lib/common/src/commons-lang-2.4-src.zip!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
|
<library name="test">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../lib/test/jboss-ejb3-embeddable-ALPHA-9.jar!/" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/../lib/test/jboss-ejb3-embeddable-thirdparty-ALPHA-9.jar!/" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/../lib/test/junit-4.5.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../lib/test/src/junit-4.5-src.zip!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -2,3 +2,6 @@ jboss.version=4.2.3.GA-1
|
|||||||
commons-lang.version=2.4
|
commons-lang.version=2.4
|
||||||
openjpa.version=1.2.0
|
openjpa.version=1.2.0
|
||||||
serp.version=1.13.1
|
serp.version=1.13.1
|
||||||
|
junit.version=4.5
|
||||||
|
jboss-ejb3-embeddable.version=ALPHA-9
|
||||||
|
jboss-ejb3-embeddable-thirdparty.version=ALPHA-9
|
||||||
|
@ -27,4 +27,20 @@
|
|||||||
<!--<fileset refid="chile-jars"/>-->
|
<!--<fileset refid="chile-jars"/>-->
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
<path id="enhance-cp">
|
||||||
|
<fileset refid="common-lib-fs"/>
|
||||||
|
<fileset refid="server-lib-fs"/>
|
||||||
|
<pathelement location="${prod.out.dir}/${module.name}"/>
|
||||||
|
<pathelement location="${test.out.dir}/${module.name}"/>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<target name="compile-module" depends="base.compile-module">
|
||||||
|
<echo>==> enhancing ${project.dir} ${module.name}</echo>
|
||||||
|
<java classpathref="enhance-cp"
|
||||||
|
classname="org.apache.openjpa.enhance.PCEnhancer" failonerror="true">
|
||||||
|
<arg value="-properties"/>
|
||||||
|
<arg value="META-INF/cuba-persistence.xml"/>
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -8,6 +8,7 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="1.5" jdkType="JavaSDK" />
|
<orderEntry type="jdk" jdkName="1.5" jdkType="JavaSDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="test" level="project" />
|
||||||
<orderEntry type="library" name="chile" level="project" />
|
<orderEntry type="library" name="chile" level="project" />
|
||||||
<orderEntry type="library" name="server" level="project" />
|
<orderEntry type="library" name="server" level="project" />
|
||||||
<orderEntry type="library" name="common" level="project" />
|
<orderEntry type="library" name="common" level="project" />
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core;
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
public interface BaseEntity
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public interface BaseEntity extends Serializable
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||||
|
* Haulmont Technology proprietary and confidential.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
|
||||||
|
* Author: Konstantin Krivopustov
|
||||||
|
* Created: 03.11.2008 18:35:16
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
public interface EntityManagerAdapter
|
||||||
|
{
|
||||||
|
void persist(BaseEntity entity);
|
||||||
|
|
||||||
|
<T extends BaseEntity> T merge(T entity);
|
||||||
|
|
||||||
|
void remove(BaseEntity entity);
|
||||||
|
|
||||||
|
<T extends BaseEntity> T find(Class<T> clazz, Object key);
|
||||||
|
|
||||||
|
void flush();
|
||||||
|
|
||||||
|
void close();
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||||
|
* Haulmont Technology proprietary and confidential.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
|
||||||
|
* Author: Konstantin Krivopustov
|
||||||
|
* Created: 03.11.2008 18:42:58
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
import com.haulmont.cuba.core.impl.EntityManagerAdapterImpl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public interface EntityManagerFactoryAdapter extends Serializable
|
||||||
|
{
|
||||||
|
EntityManagerAdapterImpl createEntityManager();
|
||||||
|
}
|
@ -9,43 +9,40 @@
|
|||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core;
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
import com.haulmont.cuba.core.impl.LocatorImpl;
|
||||||
|
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
|
|
||||||
public class Locator
|
public abstract class Locator
|
||||||
{
|
{
|
||||||
private static Context jndiContext;
|
private static Locator instance;
|
||||||
private static PersistenceProvider persistenceProvider;
|
|
||||||
|
|
||||||
public static Context getJndiContext() {
|
private static Locator getInstance() {
|
||||||
if (jndiContext == null) {
|
if (instance == null) {
|
||||||
try {
|
instance = new LocatorImpl();
|
||||||
jndiContext = new InitialContext();
|
|
||||||
} catch (NamingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return jndiContext;
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Context getJndiContext() {
|
||||||
|
return getInstance().__getJndiContextImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PersistenceProvider getPersistenceProvider() {
|
public static PersistenceProvider getPersistenceProvider() {
|
||||||
if (persistenceProvider == null) {
|
return getInstance().__getPersistenceProvider();
|
||||||
persistenceProvider = new ManagedPersistenceProvider(getJndiContext());
|
|
||||||
}
|
|
||||||
return persistenceProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CubaEntityManager getEntityManager() {
|
public static EntityManagerAdapter getEntityManager() {
|
||||||
return getPersistenceProvider().getEntityManager();
|
return getInstance().__getPersistenceProvider().getEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T lookupLocal(String name) {
|
public static <T> T lookupLocal(String name) {
|
||||||
Context ctx = getJndiContext();
|
return (T) getInstance().__lookupLocal(name);
|
||||||
try {
|
|
||||||
return (T) ctx.lookup(name + "/local");
|
|
||||||
} catch (NamingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract Context __getJndiContextImpl();
|
||||||
|
|
||||||
|
protected abstract PersistenceProvider __getPersistenceProvider();
|
||||||
|
|
||||||
|
protected abstract Object __lookupLocal(String name);
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,7 @@ package com.haulmont.cuba.core;
|
|||||||
|
|
||||||
public interface PersistenceProvider
|
public interface PersistenceProvider
|
||||||
{
|
{
|
||||||
CubaEntityManagerFactory getEntityManagerFactory();
|
EntityManagerFactoryAdapter getEntityManagerFactory();
|
||||||
|
|
||||||
CubaEntityManager getEntityManager();
|
EntityManagerAdapter getEntityManager();
|
||||||
|
|
||||||
CubaEntityManager getEntityManager(boolean transactional);
|
|
||||||
}
|
}
|
||||||
|
54
modules/core/src/com/haulmont/cuba/core/entity/Server.java
Normal file
54
modules/core/src/com/haulmont/cuba/core/entity/Server.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||||
|
* Haulmont Technology proprietary and confidential.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
|
||||||
|
* Author: Konstantin Krivopustov
|
||||||
|
* Created: 04.11.2008 20:10:53
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core.entity;
|
||||||
|
|
||||||
|
import com.haulmont.cuba.core.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "SYS_SERVER")
|
||||||
|
public class Server implements BaseEntity
|
||||||
|
{
|
||||||
|
@Column(name = "NAME")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "ADDRESS")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Column(name = "IS_RUNNING")
|
||||||
|
private Boolean running;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRunning() {
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunning(Boolean running) {
|
||||||
|
this.running = running;
|
||||||
|
}
|
||||||
|
}
|
@ -7,15 +7,17 @@
|
|||||||
* Created: 31.10.2008 16:56:32
|
* Created: 31.10.2008 16:56:32
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core;
|
package com.haulmont.cuba.core.impl;
|
||||||
|
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||||
|
import com.haulmont.cuba.core.EntityManagerAdapter;
|
||||||
|
import com.haulmont.cuba.core.BaseEntity;
|
||||||
|
|
||||||
public class CubaEntityManager
|
public class EntityManagerAdapterImpl implements EntityManagerAdapter
|
||||||
{
|
{
|
||||||
private OpenJPAEntityManager jpaEm;
|
private OpenJPAEntityManager jpaEm;
|
||||||
|
|
||||||
CubaEntityManager(OpenJPAEntityManager jpaEntityManager) {
|
EntityManagerAdapterImpl(OpenJPAEntityManager jpaEntityManager) {
|
||||||
this.jpaEm = jpaEntityManager;
|
this.jpaEm = jpaEntityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +37,10 @@ public class CubaEntityManager
|
|||||||
return jpaEm.find(clazz, key);
|
return jpaEm.find(clazz, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void flush() {
|
||||||
|
jpaEm.flush();
|
||||||
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
jpaEm.close();
|
jpaEm.close();
|
||||||
}
|
}
|
@ -7,23 +7,24 @@
|
|||||||
* Created: 31.10.2008 16:55:55
|
* Created: 31.10.2008 16:55:55
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core;
|
package com.haulmont.cuba.core.impl;
|
||||||
|
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import com.haulmont.cuba.core.impl.EntityManagerAdapterImpl;
|
||||||
|
import com.haulmont.cuba.core.EntityManagerFactoryAdapter;
|
||||||
|
|
||||||
public class CubaEntityManagerFactory implements Serializable
|
public class EntityManagerFactoryAdapterImpl implements EntityManagerFactoryAdapter
|
||||||
{
|
{
|
||||||
private OpenJPAEntityManagerFactory jpaFactory;
|
private OpenJPAEntityManagerFactory jpaFactory;
|
||||||
|
|
||||||
CubaEntityManagerFactory(OpenJPAEntityManagerFactory jpaFactory) {
|
EntityManagerFactoryAdapterImpl(OpenJPAEntityManagerFactory jpaFactory) {
|
||||||
this.jpaFactory = jpaFactory;
|
this.jpaFactory = jpaFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CubaEntityManager createEntityManager() {
|
public EntityManagerAdapterImpl createEntityManager() {
|
||||||
OpenJPAEntityManager em = jpaFactory.createEntityManager();
|
OpenJPAEntityManager em = jpaFactory.createEntityManager();
|
||||||
return new CubaEntityManager(em);
|
return new EntityManagerAdapterImpl(em);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||||
|
* Haulmont Technology proprietary and confidential.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
|
||||||
|
* Author: Konstantin Krivopustov
|
||||||
|
* Created: 03.11.2008 19:02:51
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core.impl;
|
||||||
|
|
||||||
|
import com.haulmont.cuba.core.Locator;
|
||||||
|
import com.haulmont.cuba.core.PersistenceProvider;
|
||||||
|
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
public class LocatorImpl extends Locator
|
||||||
|
{
|
||||||
|
private Context jndiContext;
|
||||||
|
private PersistenceProvider persistenceProvider;
|
||||||
|
|
||||||
|
protected Context __getJndiContextImpl() {
|
||||||
|
if (jndiContext == null) {
|
||||||
|
try {
|
||||||
|
jndiContext = new InitialContext();
|
||||||
|
} catch (NamingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jndiContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PersistenceProvider __getPersistenceProvider() {
|
||||||
|
if (persistenceProvider == null) {
|
||||||
|
persistenceProvider = new ManagedPersistenceProvider(getJndiContext());
|
||||||
|
}
|
||||||
|
return persistenceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object __lookupLocal(String name) {
|
||||||
|
Context ctx = getJndiContext();
|
||||||
|
try {
|
||||||
|
return ctx.lookup(name + "/local");
|
||||||
|
} catch (NamingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
* Created: 01.11.2008 13:24:28
|
* Created: 01.11.2008 13:24:28
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core;
|
package com.haulmont.cuba.core.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -20,6 +20,12 @@ import javax.transaction.*;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.haulmont.cuba.core.impl.EntityManagerAdapterImpl;
|
||||||
|
import com.haulmont.cuba.core.impl.EntityManagerFactoryAdapterImpl;
|
||||||
|
import com.haulmont.cuba.core.PersistenceProvider;
|
||||||
|
import com.haulmont.cuba.core.EntityManagerFactoryAdapter;
|
||||||
|
import com.haulmont.cuba.core.EntityManagerAdapter;
|
||||||
|
|
||||||
public class ManagedPersistenceProvider implements PersistenceProvider
|
public class ManagedPersistenceProvider implements PersistenceProvider
|
||||||
{
|
{
|
||||||
private Context jndiContext;
|
private Context jndiContext;
|
||||||
@ -28,9 +34,9 @@ public class ManagedPersistenceProvider implements PersistenceProvider
|
|||||||
|
|
||||||
private boolean emfInitialized;
|
private boolean emfInitialized;
|
||||||
|
|
||||||
private Map<Transaction, CubaEntityManager> emMap = new Hashtable<Transaction, CubaEntityManager>();
|
private Map<Transaction, EntityManagerAdapterImpl> emMap = new Hashtable<Transaction, EntityManagerAdapterImpl>();
|
||||||
|
|
||||||
public static final String EMF_JNDI_NAME = "CubaEntityManagerFactory";
|
public static final String EMF_JNDI_NAME = "EntityManagerFactoryAdapterImpl";
|
||||||
|
|
||||||
public static final String TM_JNDI_NAME = "java:/TransactionManager";
|
public static final String TM_JNDI_NAME = "java:/TransactionManager";
|
||||||
|
|
||||||
@ -40,15 +46,15 @@ public class ManagedPersistenceProvider implements PersistenceProvider
|
|||||||
this.jndiContext = jndiContext;
|
this.jndiContext = jndiContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CubaEntityManagerFactory getEntityManagerFactory() {
|
public EntityManagerFactoryAdapter getEntityManagerFactory() {
|
||||||
synchronized (mutex) {
|
synchronized (mutex) {
|
||||||
if (!emfInitialized) {
|
if (!emfInitialized) {
|
||||||
log.debug("Create new EntityManagerFactory");
|
log.debug("Creating new EntityManagerFactory");
|
||||||
OpenJPAEntityManagerFactory jpaFactory =
|
OpenJPAEntityManagerFactory jpaFactory =
|
||||||
OpenJPAPersistence.createEntityManagerFactory("cuba", "META-INF/cuba-persistence.xml");
|
OpenJPAPersistence.createEntityManagerFactory("cuba", "META-INF/cuba-persistence.xml");
|
||||||
CubaEntityManagerFactory emf = new CubaEntityManagerFactory(jpaFactory);
|
EntityManagerFactoryAdapter emf = new EntityManagerFactoryAdapterImpl(jpaFactory);
|
||||||
try {
|
try {
|
||||||
log.debug("Bind new EntityManagerFactory to JNDI context " + EMF_JNDI_NAME);
|
log.debug("Binding new EntityManagerFactory to JNDI context " + EMF_JNDI_NAME);
|
||||||
jndiContext.bind(EMF_JNDI_NAME, emf);
|
jndiContext.bind(EMF_JNDI_NAME, emf);
|
||||||
} catch (NamingException e) {
|
} catch (NamingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -57,38 +63,28 @@ public class ManagedPersistenceProvider implements PersistenceProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return (CubaEntityManagerFactory) jndiContext.lookup(EMF_JNDI_NAME);
|
return (EntityManagerFactoryAdapter) jndiContext.lookup(EMF_JNDI_NAME);
|
||||||
} catch (NamingException e) {
|
} catch (NamingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CubaEntityManager getEntityManager() {
|
public EntityManagerAdapter getEntityManager() {
|
||||||
return getEntityManager(true);
|
EntityManagerAdapterImpl em;
|
||||||
}
|
|
||||||
|
|
||||||
public CubaEntityManager getEntityManager(boolean transactional) {
|
|
||||||
CubaEntityManager em;
|
|
||||||
try {
|
try {
|
||||||
TransactionManager tm = getTransactionManager();
|
TransactionManager tm = getTransactionManager();
|
||||||
Transaction tx = tm.getTransaction();
|
Transaction tx = tm.getTransaction();
|
||||||
if (transactional) {
|
if (tx != null) {
|
||||||
if (tx == null) {
|
|
||||||
log.trace("Begin new transaction");
|
|
||||||
tm.begin();
|
|
||||||
tx = tm.getTransaction();
|
|
||||||
}
|
|
||||||
em = emMap.get(tx);
|
em = emMap.get(tx);
|
||||||
if (em == null) {
|
if (em == null) {
|
||||||
log.trace("Create new EntityManager for transaction " + tx);
|
log.trace("Creating new EntityManager for transaction " + tx);
|
||||||
em = getEntityManagerFactory().createEntityManager();
|
em = getEntityManagerFactory().createEntityManager();
|
||||||
registerSync(tx, em);
|
registerSync(tx, em);
|
||||||
emMap.put(tx, em);
|
emMap.put(tx, em);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (tx != null)
|
log.trace("Creating new non-transactional EntityManager");
|
||||||
throw new RuntimeException("Unable to get non-transactional EntityManager: JTA transaction exists");
|
|
||||||
em = getEntityManagerFactory().createEntityManager();
|
em = getEntityManagerFactory().createEntityManager();
|
||||||
}
|
}
|
||||||
return em;
|
return em;
|
||||||
@ -96,18 +92,16 @@ public class ManagedPersistenceProvider implements PersistenceProvider
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (SystemException e) {
|
} catch (SystemException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (NotSupportedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSync(final javax.transaction.Transaction tx, final CubaEntityManager em) {
|
private void registerSync(final javax.transaction.Transaction tx, final EntityManagerAdapter em) {
|
||||||
try {
|
try {
|
||||||
tx.registerSynchronization(
|
tx.registerSynchronization(
|
||||||
new Synchronization()
|
new Synchronization()
|
||||||
{
|
{
|
||||||
public void beforeCompletion() {
|
public void beforeCompletion() {
|
||||||
log.trace("Close EntityManager for transaction " + tx);
|
log.trace("Closing EntityManager for transaction " + tx);
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
13
modules/core/test/META-INF/cuba-persistence.xml
Normal file
13
modules/core/test/META-INF/cuba-persistence.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
|
||||||
|
<persistence-unit name="cuba" transaction-type="JTA">
|
||||||
|
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
||||||
|
<jta-data-source>java:/DefaultDS</jta-data-source>
|
||||||
|
<class>com.haulmont.cuba.core.entity.Server</class>
|
||||||
|
<properties>
|
||||||
|
<property name="openjpa.Log" value="log4j"/>
|
||||||
|
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72"/>
|
||||||
|
<property name="openjpa.jdbc.DBDictionary" value="hsql(SimulateLocking=true)"/>
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
</persistence>
|
@ -1,8 +0,0 @@
|
|||||||
package com.haulmont.cuba.core;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author: Konstantin Krivopustov
|
|
||||||
* Date: 20.10.2008 21:06:41
|
|
||||||
*/
|
|
||||||
public class CubaCoreTest /*extends TestCase*/ {
|
|
||||||
}
|
|
27
modules/core/test/com/haulmont/cuba/core/LocatorTest.java
Normal file
27
modules/core/test/com/haulmont/cuba/core/LocatorTest.java
Normal 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: 04.11.2008 10:23:52
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
import javax.transaction.TransactionManager;
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
public class LocatorTest extends ServerTestCase
|
||||||
|
{
|
||||||
|
public void testJndi() {
|
||||||
|
Context ctx = Locator.getJndiContext();
|
||||||
|
try {
|
||||||
|
TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
|
||||||
|
assertNotNull(tm);
|
||||||
|
} catch (NamingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||||
|
* Haulmont Technology proprietary and confidential.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
|
||||||
|
* Author: Konstantin Krivopustov
|
||||||
|
* Created: 04.11.2008 20:50:16
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
import com.haulmont.cuba.core.entity.Server;
|
||||||
|
|
||||||
|
public class PersistenceTest extends ServerTestCase
|
||||||
|
{
|
||||||
|
public void test() {
|
||||||
|
EntityManagerAdapter em = Locator.getEntityManager();
|
||||||
|
assertNotNull(em);
|
||||||
|
Server server = new Server();
|
||||||
|
server.setName("localhost");
|
||||||
|
server.setAddress("127.0.0.1");
|
||||||
|
server.setRunning(true);
|
||||||
|
em.persist(server);
|
||||||
|
}
|
||||||
|
}
|
20
modules/core/test/com/haulmont/cuba/core/ServerTestCase.java
Normal file
20
modules/core/test/com/haulmont/cuba/core/ServerTestCase.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||||
|
* Haulmont Technology proprietary and confidential.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
|
||||||
|
* Author: Konstantin Krivopustov
|
||||||
|
* Created: 04.11.2008 10:29:29
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class ServerTestCase extends TestCase
|
||||||
|
{
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
TestContainer.start();
|
||||||
|
}
|
||||||
|
}
|
33
modules/core/test/com/haulmont/cuba/core/TestContainer.java
Normal file
33
modules/core/test/com/haulmont/cuba/core/TestContainer.java
Normal 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: 04.11.2008 11:26:12
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
package com.haulmont.cuba.core;
|
||||||
|
|
||||||
|
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
|
||||||
|
|
||||||
|
public class TestContainer
|
||||||
|
{
|
||||||
|
private static boolean started;
|
||||||
|
|
||||||
|
public static void start() {
|
||||||
|
if (started)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EJB3StandaloneBootstrap.boot(null);
|
||||||
|
EJB3StandaloneBootstrap.scanClasspath("build/20-cuba-core.jar");
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stop() {
|
||||||
|
if (!started)
|
||||||
|
return;
|
||||||
|
EJB3StandaloneBootstrap.shutdown();
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
}
|
360
modules/core/test/ejb3-interceptors-aop.xml
Normal file
360
modules/core/test/ejb3-interceptors-aop.xml
Normal file
@ -0,0 +1,360 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE aop PUBLIC
|
||||||
|
"-//JBoss//DTD JBOSS AOP 1.0//EN"
|
||||||
|
"http://www.jboss.org/aop/dtd/jboss-aop_1_0.dtd">
|
||||||
|
|
||||||
|
<aop>
|
||||||
|
<interceptor class="org.jboss.aspects.remoting.InvokeRemoteInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.aspects.security.SecurityClientInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.aspects.tx.ClientTxPropagationInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.remoting.IsLocalInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.aspects.remoting.ClusterChooserInterceptor" scope="PER_VM"/>
|
||||||
|
|
||||||
|
<interceptor class="org.jboss.aspects.tx.TxPropagationInterceptor" scope="PER_VM"/>
|
||||||
|
|
||||||
|
<stack name="ServiceClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<stack name="AsynchronousStatelessSessionClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<stack name="AsynchronousStatefulSessionClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<stack name="StatelessSessionClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<stack name="StatefulSessionClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<stack name="ClusteredStatelessSessionClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<stack name="ClusteredStatefulSessionClientInterceptors">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
|
||||||
|
</stack>
|
||||||
|
|
||||||
|
<interceptor class="org.jboss.ejb3.asynchronous.AsynchronousInterceptor" scope="PER_CLASS"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.ENCPropagationInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor name="Basic Authorization" factory="org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorFactory" scope="PER_CLASS"/>
|
||||||
|
<interceptor name="JACC Authorization" factory="org.jboss.ejb3.security.JaccAuthorizationInterceptorFactory" scope="PER_CLASS"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.security.AuthenticationInterceptorFactory" scope="PER_CLASS"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" scope="PER_CLASS"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.stateless.StatelessInstanceInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.stateful.StatefulInstanceInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.service.ServiceSingletonInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.cache.StatefulReplicationInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.stateful.StatefulRemoveFactory" scope="PER_CLASS_JOINPOINT"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.tx.TxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory" scope="PER_CLASS_JOINPOINT"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory" scope="PER_CLASS"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
|
||||||
|
<interceptor factory="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory" scope="PER_CLASS"/>
|
||||||
|
<interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
|
||||||
|
|
||||||
|
<domain name="Stateless Bean">
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
|
||||||
|
<interceptor-ref name="Basic Authorization"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
|
||||||
|
@org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="JACC Stateless Bean">
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
|
||||||
|
<interceptor-ref name="JACC Authorization"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
|
||||||
|
@org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="Base Stateful Bean">
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
|
||||||
|
<interceptor-ref name="Basic Authorization"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
|
||||||
|
@org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
|
||||||
|
<!-- NON Clustered cache configuration -->
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND !class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
|
||||||
|
</annotation>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.PersistenceManager) AND !class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.simple.PersistenceManager (org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.class)
|
||||||
|
</annotation>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300)
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<!-- Clustered cache configuration -->
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
|
||||||
|
</annotation>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="JACC Stateful Bean">
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
|
||||||
|
<interceptor-ref name="JACC Authorization"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
|
||||||
|
@org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<!-- NON Clustered cache configuration -->
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND !class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
|
||||||
|
</annotation>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.PersistenceManager) AND !class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.simple.PersistenceManager (org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.class)
|
||||||
|
</annotation>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300)
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<!-- Clustered cache configuration -->
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
|
||||||
|
</annotation>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
|
||||||
|
@org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="Embedded Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
|
||||||
|
<!-- NON Clustered cache configuration -->
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache)">
|
||||||
|
@org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.NoPassivationCache.class)
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="Message Driven Bean">
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
|
||||||
|
@org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="Consumer Bean">
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..)) AND (has(* *->@org.jboss.annotation.ejb.CurrentMessage(..)) OR hasfield(* *->@org.jboss.annotation.ejb.CurrentMessage))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
|
||||||
|
@org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
|
||||||
|
</annotation>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="Service Bean">
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
|
||||||
|
<interceptor-ref name="Basic Authorization"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
<domain name="JACC Service Bean">
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
|
||||||
|
<interceptor-ref name="Basic Authorization"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..))">
|
||||||
|
<interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
|
||||||
|
</bind>
|
||||||
|
<bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
|
||||||
|
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
|
||||||
|
</bind>
|
||||||
|
</domain>
|
||||||
|
|
||||||
|
|
||||||
|
</aop>
|
175
modules/core/test/embedded-jboss-beans.xml
Normal file
175
modules/core/test/embedded-jboss-beans.xml
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
|
||||||
|
xmlns="urn:jboss:bean-deployer">
|
||||||
|
<bean name="Naming" class="org.jnp.server.SingletonNamingServer"/>
|
||||||
|
|
||||||
|
<bean name="InitialContextProperties" class="java.util.Hashtable">
|
||||||
|
<constructor>
|
||||||
|
<parameter class="java.util.Map">
|
||||||
|
<map keyClass="java.lang.String" valueClass="java.lang.String">
|
||||||
|
<entry>
|
||||||
|
<key>java.naming.factory.initial</key>
|
||||||
|
<value>org.jnp.interfaces.LocalOnlyContextFactory</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>java.naming.factory.url.pkgs</key>
|
||||||
|
<value>org.jboss.naming:org.jnp.interfaces</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</parameter>
|
||||||
|
</constructor>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="java:comp/Initializer" class="org.jboss.ejb3.embedded.JavaCompInitializer">
|
||||||
|
<property name="jndiProperties"><inject bean="InitialContextProperties"/></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="XidFactory" class="org.jboss.tm.XidFactoryImpl"/>
|
||||||
|
|
||||||
|
<bean name="XidFactoryMBean" class="org.jboss.ejb3.embedded.XidFactoryMBean">
|
||||||
|
<constructor>
|
||||||
|
<parameter class="org.jboss.tm.XidFactoryBase">
|
||||||
|
<inject bean="XidFactory"/>
|
||||||
|
</parameter>
|
||||||
|
</constructor>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="TransactionManagerInitializer" class="org.jboss.tm.TransactionManagerInitializer">
|
||||||
|
<property name="xidFactory"><inject bean="XidFactory"/></property>
|
||||||
|
<property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="UserTransaction" class="org.jboss.ejb3.embedded.UserTransactionImpl">
|
||||||
|
<demand>TransactionManagerInitializer</demand>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="UserTransactionBinding" class="org.jboss.ejb3.embedded.JndiBinder">
|
||||||
|
<property name="jndiProperties"><inject bean="InitialContextProperties"/></property>
|
||||||
|
<property name="target"><inject bean="UserTransaction"/></property>
|
||||||
|
<property name="bindTo">UserTransaction</property>
|
||||||
|
<property name="serializable">false</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<bean name="TransactionManager" class="java.lang.Object">
|
||||||
|
<constructor factoryMethod="getTransactionManager">
|
||||||
|
<factory bean="TransactionManagerInitializer"/>
|
||||||
|
</constructor>
|
||||||
|
</bean>
|
||||||
|
<bean name="CachedConnectionManager" class="org.jboss.resource.connectionmanager.CachedConnectionManagerReference">
|
||||||
|
<property name="transactionManager"><inject bean="TransactionManager"/></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<bean class="org.jboss.jdbc.HypersonicDatabase"
|
||||||
|
name="jboss:service=Hypersonic,database=localDB">
|
||||||
|
<property name="database">localDB</property>
|
||||||
|
<property name="inProcessMode">true</property>
|
||||||
|
<property name="dbDataDir">.</property>
|
||||||
|
</bean>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<bean name="DefaultDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
|
||||||
|
<property name="driverClass">org.hsqldb.jdbcDriver</property>
|
||||||
|
<property name="connectionURL">jdbc:hsqldb:.</property>
|
||||||
|
<!-- <property name="connectionURL">jdbc:hsqldb:./hypersonic/localDB</property> -->
|
||||||
|
<property name="userName">sa</property>
|
||||||
|
<property name="jndiName">java:/DefaultDS</property>
|
||||||
|
<property name="minSize">0</property>
|
||||||
|
<property name="maxSize">10</property>
|
||||||
|
<property name="blockingTimeout">1000</property>
|
||||||
|
<property name="idleTimeout">100000</property>
|
||||||
|
<property name="transactionManager"><inject bean="TransactionManager"/></property>
|
||||||
|
<property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
|
||||||
|
<property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="DefaultDS" class="java.lang.Object">
|
||||||
|
<constructor factoryMethod="getDatasource">
|
||||||
|
<factory bean="DefaultDSBootstrap"/>
|
||||||
|
</constructor>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<bean name="TimerServiceFactory" class="org.jboss.ejb3.timerservice.quartz.QuartzTimerServiceFactory">
|
||||||
|
<property name="properties">
|
||||||
|
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT
|
||||||
|
org.quartz.jobStore.nonManagedTXDataSource=myDS
|
||||||
|
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
|
||||||
|
org.quartz.jobStore.tablePrefix=QRTZ_
|
||||||
|
org.quartz.jobStore.dataSource=myDS
|
||||||
|
|
||||||
|
# To get it to work with hypersonic
|
||||||
|
# FIXME: this doesn't lock the row
|
||||||
|
org.quartz.jobStore.selectWithLockSQL=SELECT * FROM qrtz_locks WHERE lock_name = ?
|
||||||
|
|
||||||
|
# from quartz.properties
|
||||||
|
org.quartz.scheduler.instanceName=JBossEJB3QuartzScheduler
|
||||||
|
org.quartz.scheduler.rmi.export=false
|
||||||
|
org.quartz.scheduler.rmi.proxy=false
|
||||||
|
org.quartz.scheduler.wrapJobExecutionInUserTransaction=false
|
||||||
|
|
||||||
|
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
|
||||||
|
org.quartz.threadPool.threadCount=10
|
||||||
|
org.quartz.threadPool.threadPriority=5
|
||||||
|
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
|
||||||
|
|
||||||
|
org.quartz.jobStore.misfireThreshold=60000
|
||||||
|
</property>
|
||||||
|
<property name="dataSource">java:/DefaultDS</property>
|
||||||
|
<property name="sqlProperties">
|
||||||
|
CREATE_DB_ON_STARTUP = TRUE
|
||||||
|
|
||||||
|
CREATE_TABLE_JOB_DETAILS = CREATE TABLE qrtz_job_details(JOB_NAME VARCHAR(80) NOT NULL, JOB_GROUP VARCHAR(80) NOT NULL, \
|
||||||
|
DESCRIPTION VARCHAR(120) NULL, JOB_CLASS_NAME VARCHAR(128) NOT NULL, IS_DURABLE VARCHAR(1) NOT NULL, \
|
||||||
|
IS_VOLATILE VARCHAR(1) NOT NULL, IS_STATEFUL VARCHAR(1) NOT NULL, REQUESTS_RECOVERY VARCHAR(1) NOT NULL, \
|
||||||
|
JOB_DATA BINARY NULL, PRIMARY KEY (JOB_NAME,JOB_GROUP))
|
||||||
|
CREATE_TABLE_JOB_LISTENERS = CREATE TABLE qrtz_job_listeners(JOB_NAME VARCHAR(80) NOT NULL, JOB_GROUP VARCHAR(80) NOT NULL, \
|
||||||
|
JOB_LISTENER VARCHAR(80) NOT NULL, PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER), FOREIGN KEY (JOB_NAME,JOB_GROUP) \
|
||||||
|
REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP))
|
||||||
|
CREATE_TABLE_TRIGGERS = CREATE TABLE qrtz_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, TRIGGER_GROUP VARCHAR(80) NOT NULL, \
|
||||||
|
JOB_NAME VARCHAR(80) NOT NULL, JOB_GROUP VARCHAR(80) NOT NULL, IS_VOLATILE VARCHAR(1) NOT NULL, DESCRIPTION VARCHAR(120) NULL, \
|
||||||
|
NEXT_FIRE_TIME NUMERIC(13) NULL, PREV_FIRE_TIME NUMERIC(13) NULL, TRIGGER_STATE VARCHAR(16) NOT NULL, \
|
||||||
|
TRIGGER_TYPE VARCHAR(8) NOT NULL, START_TIME NUMERIC(13) NOT NULL, END_TIME NUMERIC(13) NULL, CALENDAR_NAME VARCHAR(80) NULL, \
|
||||||
|
MISFIRE_INSTR NUMERIC(2) NULL, JOB_DATA BINARY NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (JOB_NAME,JOB_GROUP) \
|
||||||
|
REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP))
|
||||||
|
CREATE_TABLE_SIMPLE_TRIGGERS = CREATE TABLE qrtz_simple_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
TRIGGER_GROUP VARCHAR(80) NOT NULL, REPEAT_COUNT NUMERIC(7) NOT NULL, REPEAT_INTERVAL NUMERIC(12) NOT NULL, \
|
||||||
|
TIMES_TRIGGERED NUMERIC(7) NOT NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) \
|
||||||
|
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
|
||||||
|
CREATE_TABLE_CRON_TRIGGERS = CREATE TABLE qrtz_cron_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
TRIGGER_GROUP VARCHAR(80) NOT NULL, CRON_EXPRESSION VARCHAR(80) NOT NULL, TIME_ZONE_ID VARCHAR(80), \
|
||||||
|
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) \
|
||||||
|
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
|
||||||
|
CREATE_TABLE_BLOB_TRIGGERS = CREATE TABLE qrtz_blob_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
TRIGGER_GROUP VARCHAR(80) NOT NULL, BLOB_DATA BINARY NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), \
|
||||||
|
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
|
||||||
|
CREATE_TABLE_TRIGGER_LISTENERS = CREATE TABLE qrtz_trigger_listeners(TRIGGER_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
TRIGGER_GROUP VARCHAR(80) NOT NULL, TRIGGER_LISTENER VARCHAR(80) NOT NULL, \
|
||||||
|
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) \
|
||||||
|
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
|
||||||
|
CREATE_TABLE_CALENDARS = CREATE TABLE qrtz_calendars(CALENDAR_NAME VARCHAR(80) NOT NULL, CALENDAR BINARY NOT NULL, \
|
||||||
|
PRIMARY KEY (CALENDAR_NAME))
|
||||||
|
CREATE_TABLE_PAUSED_TRIGGER_GRPS = CREATE TABLE qrtz_paused_trigger_grps(TRIGGER_GROUP VARCHAR(80) NOT NULL, \
|
||||||
|
PRIMARY KEY (TRIGGER_GROUP))
|
||||||
|
CREATE_TABLE_FIRED_TRIGGERS = CREATE TABLE qrtz_fired_triggers(ENTRY_ID VARCHAR(95) NOT NULL, TRIGGER_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
TRIGGER_GROUP VARCHAR(80) NOT NULL, IS_VOLATILE VARCHAR(1) NOT NULL, INSTANCE_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
FIRED_TIME NUMERIC(13) NOT NULL, STATE VARCHAR(16) NOT NULL, JOB_NAME VARCHAR(80) NULL, JOB_GROUP VARCHAR(80) NULL, \
|
||||||
|
IS_STATEFUL VARCHAR(1) NULL, REQUESTS_RECOVERY VARCHAR(1) NULL, PRIMARY KEY (ENTRY_ID))
|
||||||
|
CREATE_TABLE_SCHEDULER_STATE = CREATE TABLE qrtz_scheduler_state(INSTANCE_NAME VARCHAR(80) NOT NULL, \
|
||||||
|
LAST_CHECKIN_TIME NUMERIC(13) NOT NULL, CHECKIN_INTERVAL NUMERIC(13) NOT NULL, RECOVERER VARCHAR(80) NULL, \
|
||||||
|
PRIMARY KEY (INSTANCE_NAME))
|
||||||
|
CREATE_TABLE_LOCKS = CREATE TABLE qrtz_locks(LOCK_NAME VARCHAR(40) NOT NULL, PRIMARY KEY (LOCK_NAME))
|
||||||
|
INSERT_TRIGGER_ACCESS = INSERT INTO qrtz_locks values('TRIGGER_ACCESS')
|
||||||
|
INSERT_JOB_ACCESS = INSERT INTO qrtz_locks values('JOB_ACCESS')
|
||||||
|
INSERT_CALENDAR_ACCESS = INSERT INTO qrtz_locks values('CALENDAR_ACCESS')
|
||||||
|
INSERT_STATE_ACCESS = INSERT INTO qrtz_locks values('STATE_ACCESS')
|
||||||
|
INSERT_MISFIRE_ACCESS = INSERT INTO qrtz_locks values('MISFIRE_ACCESS')
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
</deployment>
|
2
modules/core/test/jndi.properties
Normal file
2
modules/core/test/jndi.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
|
||||||
|
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
|
37
modules/core/test/log4j.xml
Normal file
37
modules/core/test/log4j.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<!-- ===================================================================== -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Log4j Configuration -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- ===================================================================== -->
|
||||||
|
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
| For more configuration infromation and examples see the Jakarta Log4j
|
||||||
|
| owebsite: http://jakarta.apache.org/log4j
|
||||||
|
-->
|
||||||
|
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
|
||||||
|
|
||||||
|
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
|
||||||
|
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
|
||||||
|
<param name="Target" value="System.out"/>
|
||||||
|
<param name="Threshold" value="INFO"/>
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Messagen -->
|
||||||
|
<!--
|
||||||
|
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
|
||||||
|
-->
|
||||||
|
<param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
@ -12,6 +12,7 @@
|
|||||||
<orderEntry type="module" module-name="core" />
|
<orderEntry type="module" module-name="core" />
|
||||||
<orderEntry type="library" name="server" level="project" />
|
<orderEntry type="library" name="server" level="project" />
|
||||||
<orderEntry type="library" name="common" level="project" />
|
<orderEntry type="library" name="common" level="project" />
|
||||||
|
<orderEntry type="library" name="test" level="project" />
|
||||||
<orderEntryProperties />
|
<orderEntryProperties />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user