当前位置: 首页>>代码示例>>Java>>正文


Java LocalInitialContextFactory类代码示例

本文整理汇总了Java中org.apache.openejb.core.LocalInitialContextFactory的典型用法代码示例。如果您正苦于以下问题:Java LocalInitialContextFactory类的具体用法?Java LocalInitialContextFactory怎么用?Java LocalInitialContextFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalInitialContextFactory类属于org.apache.openejb.core包,在下文中一共展示了LocalInitialContextFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Before
public void setUp() throws OpenEJBException, NamingException, IOException {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();

    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

    final AppModule app = new AppModule(ResourcesJsonTest.class.getClassLoader(), ResourcesJsonTest.class.getSimpleName());

    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(ConfiguredThroughJSonBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    app.getEjbModules().iterator().next().getAltDDs().put("resources.json", getClass().getClassLoader().getResource("appresource.resources.json"));

    assembler.createApplication(config.configureApplication(app));

    final Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    properties.setProperty("openejb.embedded.initialcontext.close", "destroy");

    // some hack to be sure to call destroy()
    context = new InitialContext(properties);

    bean = (ConfiguredThroughJSonBean) context.lookup("ConfiguredThroughJSonBeanLocalBean");
}
 
开发者ID:apache,项目名称:tomee,代码行数:27,代码来源:ResourcesJsonTest.java

示例2: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Before
public void setUp() throws OpenEJBException, NamingException, IOException {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();

    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

    final AppModule app = new AppModule(OpenEJBXmlByModuleTest.class.getClassLoader(), OpenEJBXmlByModuleTest.class.getSimpleName());

    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(UselessBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    app.getEjbModules().iterator().next().getAltDDs().put("resources.xml", getClass().getClassLoader().getResource("META-INF/resource/appresource.openejb.xml"));

    assembler.createApplication(config.configureApplication(app));

    final Properties properties = new Properties();
    properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    properties.setProperty("openejb.embedded.initialcontext.close", "destroy");

    // some hack to be sure to call destroy()
    context = new InitialContext(properties);

    bean = (UselessBean) context.lookup("UselessBeanLocalBean");
}
 
开发者ID:apache,项目名称:tomee,代码行数:27,代码来源:OpenEJBXmlByModuleTest.java

示例3: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();

    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    statefulContainerInfo.properties.setProperty("AccessTimeout", "0 milliseconds");

    // containers
    assembler.createContainer(statefulContainerInfo);

    // Setup the descriptor information

    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(BlueStatelessBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean(RedStatefulBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean(LegacyStatefulBean.class));

    assembler.createApplication(config.configureApplication(ejbJar));
}
 
开发者ID:apache,项目名称:tomee,代码行数:26,代码来源:StatefulTransactionLockingTest.java

示例4: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
public void setUp() throws Exception {

        final ConfigurationFactory config = new ConfigurationFactory();
        final Assembler assembler = new Assembler();

        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

        assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));

        final EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
        assertNotNull(ejbJar);

        assembler.createApplication(ejbJar);

        final Properties properties = new Properties(System.getProperties());
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
        ctx = new InitialContext(properties);
    }
 
开发者ID:apache,项目名称:tomee,代码行数:21,代码来源:StatelessInterceptorTest.java

示例5: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    exception.set(false);
    MySingleton.instances.set(0);

    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();

    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

    // containers
    assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));

    // Setup the descriptor information

    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(MySingleton.class));

    assembler.createApplication(config.configureApplication(ejbJar));
}
 
开发者ID:apache,项目名称:tomee,代码行数:24,代码来源:SingletonLazyInstantiationTest.java

示例6: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    oldWhitelist = System.getProperty("tomee.serialization.class.whitelist");
    oldBlacklist = System.getProperty("tomee.serialization.class.blacklist");

    System.setProperty("tomee.serialization.class.whitelist", "org.apache.openejb.,java.lang.SecurityException,java.lang.RuntimeException,java.lang.Exception,"
            + "java.lang.Throwable,java.lang.StackTraceElement,java.util.Collections,java.util.ArrayList,java.util.Properties,java.util.Hashtable,java.util.HashSet,"
            + "java.net.URI,java.util.TreeSet,java.util.LinkedHashSet,java.lang.String");

    System.setProperty("tomee.serialization.class.blacklist", "-");

    config = new ConfigurationFactory();
    assembler = new Assembler();

    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));

    final Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    context = new InitialContext(props);
}
 
开发者ID:apache,项目名称:tomee,代码行数:24,代码来源:EjbObjectInputStreamTest.java

示例7: getInitialContext

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Override
public Context getInitialContext(final Hashtable<?, ?> environment) throws NamingException {
    final InitialContext delegate = new InitialContext(new Properties() {{
        setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    }});
    return Context.class.cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[]{Context.class}, new InvocationHandler() {
        @Override
        // convert jdbc/foo to openejb:Resource/jdbc/foo since jdbc/xxx is not standard - useful for ee tests
        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
            if ("lookup".equals(method.getName()) && String.class.isInstance(args[0]) && String.class.cast(args[0]).startsWith("jdbc")) {
                return method.invoke(delegate, "openejb:Resource/" + args[0]);
            }
            return method.invoke(delegate, args);
        }
    }));
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:17,代码来源:TckContextFactory.java

示例8: lookup

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
public <T> T lookup(final Class<T> clazz, final String jndiName) throws NamingException {
    Properties p = new Properties();
    p.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

    ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    try {
        return (T) new InitialContext(p).lookup(jndiName);
    } finally {
        Thread.currentThread().setContextClassLoader(oldCl);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:AbstractCommand.java

示例9: deployer

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
private static Deployer deployer() throws NamingException {
    final Properties p = new Properties();
    p.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

    final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(DeployerEjb.class.getClassLoader());
    try {
        return (Deployer) new InitialContext(p).lookup("openejb/DeployerBusinessRemote");
    } finally {
        Thread.currentThread().setContextClassLoader(oldCl);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:JMXDeployer.java

示例10: setUp

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
protected void setUp() throws Exception {
    config = new ConfigurationFactory();
    assembler = new Assembler();

    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));

    final Properties props = new Properties();
    props.setProperty(Context.SECURITY_PRINCIPAL, "jonathan");
    props.setProperty(Context.SECURITY_CREDENTIALS, "secret");
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    context = new InitialContext(props);
}
 
开发者ID:apache,项目名称:tomee,代码行数:16,代码来源:EjbSecurityRoleRefTest.java

示例11: test

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
public void test() throws Exception {

        final Properties properties = new Properties();
        properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
        final InitialContext context = new InitialContext(properties);
        context.bind("inject", this);

    }
 
开发者ID:apache,项目名称:tomee,代码行数:9,代码来源:LocalClientNoInjectionTest.java

示例12: test

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
@Override
public void test() throws Exception {
    final Properties properties = new Properties();
    properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final InitialContext context = new InitialContext(properties);
    context.bind("inject", this);

    assertRefs();

}
 
开发者ID:apache,项目名称:tomee,代码行数:11,代码来源:LocalClientSubclassTest.java

示例13: test

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
public void test() throws Exception {

        final Properties properties = new Properties();
        properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
        final InitialContext context = new InitialContext(properties);
        context.bind("inject", this);

        assertRefs();
    }
 
开发者ID:apache,项目名称:tomee,代码行数:10,代码来源:LocalClientTest.java

示例14: test

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();

    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(GreenBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean(RedBean.class));

    final EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());

    ejbModule.getOpenejbJar().addEjbDeployment(new EjbDeployment(null, "foo/bar/baz/Green", "GreenBean"));
    ejbModule.getOpenejbJar().addEjbDeployment(new EjbDeployment(null, "foo/bar/baz/Red", "RedBean"));

    final EjbJarInfo info = config.configureApplication(ejbModule);
    assembler.createApplication(info);

    final InitialContext initialContext = new InitialContext();
    final Color green = (Color) initialContext.lookup("foo/bar/baz/GreenLocal");
    final Color red = (Color) initialContext.lookup("foo/bar/baz/RedLocal");

    red.test();
}
 
开发者ID:apache,项目名称:tomee,代码行数:28,代码来源:MappedNameTest.java

示例15: configureAssembler

import org.apache.openejb.core.LocalInitialContextFactory; //导入依赖的package包/类
private Assembler configureAssembler(final String defaultUser) throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();

    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));

    final SecurityServiceInfo serviceInfo = new SecurityServiceInfo();
    serviceInfo.service = "SecurityService";
    serviceInfo.className = SecurityServiceImpl.class.getName();
    serviceInfo.id = "New Security Service";
    serviceInfo.properties = new Properties();
    if (defaultUser != null) {
        // override the default user
        serviceInfo.properties.setProperty("DefaultUser", defaultUser);

    }

    assembler.createSecurityService(serviceInfo);

    // containers
    assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));

    final EjbJar ejbJar = new EjbJar("SecurityTest");

    ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean(BarBean.class));

    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);

    assembler.createApplication(ejbJarInfo);

    return assembler;
}
 
开发者ID:apache,项目名称:tomee,代码行数:37,代码来源:SecurityTest.java


注:本文中的org.apache.openejb.core.LocalInitialContextFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。