本文整理匯總了Java中javax.naming.spi.NamingManager.setObjectFactoryBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java NamingManager.setObjectFactoryBuilder方法的具體用法?Java NamingManager.setObjectFactoryBuilder怎麽用?Java NamingManager.setObjectFactoryBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.spi.NamingManager
的用法示例。
在下文中一共展示了NamingManager.setObjectFactoryBuilder方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
@Override
public void start(BundleContext bundleContext) throws Exception {
try {
NamingManager.setInitialContextFactoryBuilder(new DefaultContextFactoryBuilder());
NamingManager.setObjectFactoryBuilder(new DefaultObjectFactoryBuilder());
Dictionary<String, String> propertyMap = new Hashtable<>();
propertyMap.put(JNDIConstants.JNDI_URLSCHEME, "java");
bundleContext.registerService(ObjectFactory.class, new JavaURLContextFactory(), propertyMap);
//register osgi url scheme
Dictionary<String, String> osgiPropertyMap = new Hashtable<>();
osgiPropertyMap.put(JNDIConstants.JNDI_URLSCHEME, "osgi");
bundleContext.registerService(ObjectFactory.class.getName(),
new OSGiURLContextServiceFactory(), osgiPropertyMap);
// InitialContextFactory Provider should be registered with its implementation class as well as the
// InitialContextFactory class.
bundleContext.registerService(InitialContextFactory.class, new InMemoryInitialContextFactory(), null);
logger.debug("Registering JNDIContextManager OSGi service.");
bundleContext.registerService(JNDIContextManager.class, new JNDIContextManagerServiceFactory(), null);
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}
示例2: myTestSetObjectFactoryBuilder_SetNormal
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
* Set the object factory builder to a mock instance.
*
*/
public void myTestSetObjectFactoryBuilder_SetNormal()
throws NamingException {
log.setMethod("myTestSetInitialContextFactoryBuilder_SetNormal");
ObjectFactoryBuilder objectFactoryBuilder = NamingManagerTest.MockObjectFactoryBuilder
.getInstance();
NamingManager.setObjectFactoryBuilder(objectFactoryBuilder);
}
示例3: myTestSetObjectFactoryBuilder_ResetNormal
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
* Reset the object factory builder to another mock instance.
*
*/
public void myTestSetObjectFactoryBuilder_ResetNormal()
throws NamingException {
log.setMethod("myTestSetObjectFactoryBuilder_ResetNormal");
try {
NamingManager
.setObjectFactoryBuilder(new NamingManagerTest.MockObjectFactoryBuilder());
fail("Reset ObjectFactoryBuilder is forbidden!");
} catch (IllegalStateException e) {
}
}
示例4: myTestSetObjectFactoryBuilder_ResetSame
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
* Reset the object factory builder to the same mock instance.
*
*/
public void myTestSetObjectFactoryBuilder_ResetSame()
throws NamingException {
log.setMethod("myTestSetObjectFactoryBuilder_ResetSame");
try {
NamingManager
.setObjectFactoryBuilder(NamingManagerTest.MockObjectFactoryBuilder
.getInstance());
fail("Reset ObjectFactoryBuilder is forbidden!");
} catch (IllegalStateException e) {
}
}
示例5: myTestSetObjectFactoryBuilder_ResetNull
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
* Reset the object factory builder to null.
*
*/
public void myTestSetObjectFactoryBuilder_ResetNull()
throws NamingException {
log.setMethod("myTestSetObjectFactoryBuilder_ResetNull");
try {
NamingManager.setObjectFactoryBuilder(null);
fail("Reset ObjectFactoryBuilder to null is forbidden!");
} catch (IllegalStateException e) {
}
}
示例6: myTestSetObjectFactoryBuilder_SetNormal
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
* Set the object factory builder to a mock instance.
*
*/
public void myTestSetObjectFactoryBuilder_SetNormal()
throws NamingException {
log.setMethod("myTestSetObjectFactoryBuilder_SetNormal");
ObjectFactoryBuilder objectFactoryBuilder = MockObjectFactoryBuilder
.getInstance();
NamingManager.setObjectFactoryBuilder(objectFactoryBuilder);
// NamingManager.setObjectFactoryBuilder(objectFactoryBuilder);
}
示例7: myTestSetObjectFactoryBuilder_SetNull
import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
* Set the object factory builder to null.
*
*/
public void myTestSetObjectFactoryBuilder_SetNull() throws NamingException {
log.setMethod("myTestSetObjectFactoryBuilder_SetNull");
NamingManager.setObjectFactoryBuilder(null);
}