Search in sources :

Example 1 with ProxyFactoryInfo

use of org.apache.openejb.assembler.classic.ProxyFactoryInfo in project aries by apache.

the class EJBExtender method setupOpenEJB.

private void setupOpenEJB() throws OpenEJBException {
    // Avoid a ClassLoader problem
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(OpenEjbVersion.class.getClassLoader());
        OpenEjbVersion.get();
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
    Assembler a = new Assembler();
    TransactionServiceInfo tsi = new TransactionServiceInfo();
    tsi.service = "TransactionManager";
    tsi.id = "OSGi Transaction Manager";
    PassthroughFactory.add(tsi, OSGiTransactionManager.get());
    // Avoid another ClassLoader problem
    try {
        Thread.currentThread().setContextClassLoader(PassthroughFactory.class.getClassLoader());
        a.createTransactionManager(tsi);
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
    try {
        // Overwrite existing, default JPA integration with an Aries JPA integrated one
        Assembler.getContext().put(JtaEntityManagerRegistry.class.getName(), AriesPersistenceContextIntegration.get());
        SystemInstance.get().setComponent(JtaEntityManagerRegistry.class, AriesPersistenceContextIntegration.get());
    } catch (NoClassDefFoundError ncdfe) {
    // TODO log that no JPA Context integration is available
    }
    SecurityServiceInfo ssi = new SecurityServiceInfo();
    ssi.service = "SecurityService";
    ssi.id = "Pseudo Security Service";
    PassthroughFactory.add(ssi, new PseudoSecurityService());
    // Avoid another ClassLoader problem
    try {
        Thread.currentThread().setContextClassLoader(PassthroughFactory.class.getClassLoader());
        a.createSecurityService(ssi);
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
    ProxyFactoryInfo proxyFactoryInfo = new ProxyFactoryInfo();
    proxyFactoryInfo.id = "Aries ProxyFactory";
    proxyFactoryInfo.service = "ProxyFactory";
    proxyFactoryInfo.properties = new Properties();
    PassthroughFactory.add(proxyFactoryInfo, AriesProxyService.get());
    try {
        Thread.currentThread().setContextClassLoader(PassthroughFactory.class.getClassLoader());
        a.createProxyFactory(proxyFactoryInfo);
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
Also used : ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) JtaEntityManagerRegistry(org.apache.openejb.persistence.JtaEntityManagerRegistry) OpenEjbVersion(org.apache.openejb.util.OpenEjbVersion) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) PseudoSecurityService(org.apache.openejb.ri.sp.PseudoSecurityService) PassthroughFactory(org.apache.openejb.assembler.dynamic.PassthroughFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo)

Aggregations

Properties (java.util.Properties)1 Assembler (org.apache.openejb.assembler.classic.Assembler)1 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)1 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)1 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)1 PassthroughFactory (org.apache.openejb.assembler.dynamic.PassthroughFactory)1 JtaEntityManagerRegistry (org.apache.openejb.persistence.JtaEntityManagerRegistry)1 PseudoSecurityService (org.apache.openejb.ri.sp.PseudoSecurityService)1 OpenEjbVersion (org.apache.openejb.util.OpenEjbVersion)1