當前位置: 首頁>>代碼示例>>Java>>正文


Java NamingManager.getObjectInstance方法代碼示例

本文整理匯總了Java中javax.naming.spi.NamingManager.getObjectInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java NamingManager.getObjectInstance方法的具體用法?Java NamingManager.getObjectInstance怎麽用?Java NamingManager.getObjectInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.spi.NamingManager的用法示例。


在下文中一共展示了NamingManager.getObjectInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: next

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
@Override
public Binding next() throws NamingException {
	if (hasMore()) {
		final Entry<String, Object> entry = iterator.next();

		final String name = entry.getKey();
		Object value = entry.getValue();
		try {
			value = NamingManager.getObjectInstance(value, new CompositeName().add(name), context, environnement);
		} catch (final Throwable err) {
			final NamingException errNaming = new NamingException("Failed To Get Instance ");
			errNaming.setRootCause(err);
			throw errNaming;
		}
		return new Binding(name, value);
	}
	throw new NoSuchElementException();
}
 
開發者ID:geronimo-iia,項目名稱:winstone,代碼行數:19,代碼來源:Bindings.java

示例2: myTestGetObjectInstance_HasBuilder_BuilderNullPointerException

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * Test the behavior when factory builder throws NullPointerException.
 */
public void myTestGetObjectInstance_HasBuilder_BuilderNullPointerException()
		throws Exception {
	log
			.setMethod("myTestGetObjectInstance_HasBuilder_BuilderNullPointerException");
	Hashtable<Object, Object> env = new Hashtable<Object, Object>();
	NamingManagerTest.indicateNullPointerException(env, 1);
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env
			.put(Context.STATE_FACTORIES,
					"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactoryNoException");
	try {
		NamingManager.getObjectInstance(null, null, null, env);
		fail("Should throw NullPointerException.");
	} catch (NullPointerException e) {
		// log.log(e);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:NamingManagerBuilderTest.java

示例3: myTestGetObjectInstance_HasBuilder_BuilderNamingException

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * Test the behavior when factory builder throws NamingException.
 */
public void myTestGetObjectInstance_HasBuilder_BuilderNamingException()
		throws Exception {
	log
			.setMethod("myTestGetObjectInstance_HasBuilder_BuilderNamingException");
	Hashtable<Object, Object> env = new Hashtable<Object, Object>();
	NamingManagerTest.indicateNamingException(env, 1);
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env
			.put(Context.STATE_FACTORIES,
					"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactoryNoException");
	try {
		NamingManager.getObjectInstance(null, null, null, env);
		fail("Should throw NamingException.");
	} catch (NamingException e) {
		// log.log(e);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:NamingManagerBuilderTest.java

示例4: myTestGetObjectInstance_HasBuilder_FactoryRuntimeException

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * Test the behavior when factory throws RuntimeException.
 */
public void myTestGetObjectInstance_HasBuilder_FactoryRuntimeException()
		throws Exception {
	log
			.setMethod("myTestGetObjectInstance_HasBuilder_FactoryRuntimeException");
	Hashtable<Object, Object> env = new Hashtable<Object, Object>();
	NamingManagerTest.indicateRuntimeException(env, 2);
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env
			.put(Context.STATE_FACTORIES,
					"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactoryNoException");
	try {
		NamingManager.getObjectInstance(null, null, null, env);
		fail("Should throw RuntimeException.");
	} catch (RuntimeException e) {
		// log.log(e);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:NamingManagerBuilderTest.java

示例5: myTestGetObjectInstance_HasBuilder_FactoryNamingException

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * Test the behavior when factory throws NamingException.
 */
public void myTestGetObjectInstance_HasBuilder_FactoryNamingException()
		throws Exception {
	log
			.setMethod("myTestGetObjectInstance_HasBuilder_FactoryNamingException");
	Hashtable<Object, Object> env = new Hashtable<Object, Object>();
	NamingManagerTest.indicateNamingException(env, 2);
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env
			.put(Context.STATE_FACTORIES,
					"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactoryNoException");
	try {
		NamingManager.getObjectInstance(null, null, null, env);
		fail("Should throw NamingException.");
	} catch (NamingException e) {
		// log.log(e);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:NamingManagerBuilderTest.java

示例6: myTestGetObjectInstance_HasBuilder_BuilderReturnNull

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * Test the behavior when factory builder is set but the factory builder
 * returns null.
 */
public void myTestGetObjectInstance_HasBuilder_BuilderReturnNull()
		throws Exception {
	log.setMethod("myTestGetObjectInstance_HasBuilder_BuilderReturnNull");
	Hashtable<Object, Object> env = new Hashtable<Object, Object>();
	NamingManagerTest.indicateReturnNull(env, 1);
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env
			.put(Context.STATE_FACTORIES,
					"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactoryNoException");
	try {
		NamingManager.getObjectInstance(null, null, null, env);
		fail("Should throw NullPointerException.");
	} catch (NullPointerException e) {
		// log.log(e);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:NamingManagerBuilderTest.java

示例7: testGetObjectInstance_NoBuilder_ReferenceValidFactory

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * When no factory builder is set and the fed object is Reference with a
 * valid factory name which works properly. Should return an object
 * successfully.
 * 
 * Try the same when the fed object is Referenceable.
 */
public void testGetObjectInstance_NoBuilder_ReferenceValidFactory()
		throws Exception {
	log
			.setMethod("testGetObjectInstance_NoBuilder_ReferenceValidFactory()");
	Hashtable<String, Object> env = new Hashtable<String, Object>();
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	Reference r = new Reference(
			null,
			"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory",
			null);
	Object obj = NamingManager.getObjectInstance(r, null, null, env);

	// if (null != obj) {
	// log.log(obj.toString());
	// } else {
	// log.log("Null object returned!");
	// }
	assertEquals(new MockObject(r, null, null, env), obj);

	// test Referenceable
	MockReferenceable mr = new MockReferenceable(r);
	obj = NamingManager.getObjectInstance(mr, null, null, env);
	assertEquals(new MockObject(r, null, null, env), obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:33,代碼來源:NamingManagerTest.java

示例8: testGetObjectInstance_NoBuilder_ReferenceInvalidFactory

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * When no factory builder is set and the fed object is Reference with an
 * invalid factory name. Should return the original object.
 * 
 * Try the same when the fed object is Referenceable.
 */
public void testGetObjectInstance_NoBuilder_ReferenceInvalidFactory()
		throws Exception {
	log
			.setMethod("testGetObjectInstance_NoBuilder_ReferenceInvalidFactory()");
	Hashtable<String, String> env = new Hashtable<String, String>();
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	Reference r = new Reference(null, "junk.factory", null);
	Object obj = NamingManager.getObjectInstance(r, null, null, env);
	assertSame(r, obj);

	// test Referenceable
	MockReferenceable mr = new MockReferenceable(r);
	obj = NamingManager.getObjectInstance(mr, null, null, env);
	assertSame(mr, obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:NamingManagerTest.java

示例9: testGetObjectInstance_NoBuilder_ReferenceReturnNull

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * When no factory builder is set and the fed object is Reference with a
 * valid factory name but the factory returns null. Should return null.
 * 
 * Try the same when the fed object is Referenceable.
 */
public void testGetObjectInstance_NoBuilder_ReferenceReturnNull()
		throws Exception {
	log.setMethod("testGetObjectInstance_NoBuilder_ReferenceReturnNull()");
	Hashtable<Object, Object> env = new Hashtable<Object, Object>();
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	Reference r = new Reference(
			null,
			"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory",
			null);
	indicateReturnNull(env);
	Object obj = NamingManager.getObjectInstance(r, null, null, env);
	assertNull(obj);

	// test Referenceable
	MockReferenceable mr = new MockReferenceable(r);
	indicateReturnNull(env);
	obj = NamingManager.getObjectInstance(mr, null, null, env);
	assertNull(obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:27,代碼來源:NamingManagerTest.java

示例10: testGetObjectInstance_NoBuilder_ReferenceNullTypedNonStrAddr

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * When no factory builder is set and the fed object is Reference with no
 * factory name, and there are one MockRefAddr which contains a valid URL
 * and another MockRefAddr whose type is null. Should return the original
 * object o.
 */
public void testGetObjectInstance_NoBuilder_ReferenceNullTypedNonStrAddr()
		throws Exception {
	log
			.setMethod("testGetObjectInstance_NoBuilder_ReferenceNullTypedNonStrAddr()");
	Hashtable<String, String> env = new Hashtable<String, String>();
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env.put(Context.URL_PKG_PREFIXES, "org.apache.harmony.jndi.tests.javax.naming.spi.mock");
	Reference r = new Reference(null);
	MockRefAddr mockAddr = new MockRefAddr("URL", "ftp://www.apache.org/");
	r.add(mockAddr);
	mockAddr = new MockRefAddr(null, "ftp://www.apache.org/");
	r.add(mockAddr);

	Object obj = NamingManager.getObjectInstance(r, new CompositeName(
			"compositename"), new MockContext(new Hashtable<String, Object>()), env);
	assertSame(obj, r);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:25,代碼來源:NamingManagerTest.java

示例11: testGetObjectInstance_NoBuilder_NotRef_InvalidFactory

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * When no factory builder is set, and all fed parameters are null except
 * the original object and the environment properties. The environment
 * properties contains an invalid factory name, and a valid factory name
 * that follows. Should return an object created by the valid factory.
 */
public void testGetObjectInstance_NoBuilder_NotRef_InvalidFactory()
		throws Exception {
	log
			.setMethod("testGetObjectInstance_NoBuilder_NotRef_InvalidFactory()");
	Hashtable<String, Object> env = new Hashtable<String, Object>();
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env
			.put(
					Context.OBJECT_FACTORIES,
					"junk.factory:"
							+ "org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory");

	Object obj = NamingManager.getObjectInstance(null, null, null, env);
	assertEquals(new MockObject(null, null, null, env), obj);

	obj = NamingManager.getObjectInstance(env, null, null, env);
	assertEquals(new MockObject(env, null, null, env), obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:NamingManagerTest.java

示例12: testGetObjectInstance_NoBuilder_NotRef_FactoryWithNull

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * When no factory builder is set, and all fed parameters are null except
 * the original object and the environment properties. The environment
 * properties contains a valid factory that returns null. Should return the
 * original object.
 */
public void testGetObjectInstance_NoBuilder_NotRef_FactoryWithNull()
		throws Exception {
	log
			.setMethod("testGetObjectInstance_NoBuilder_NotRef_FactoryWithNull()");
	Hashtable<String, String> env = new Hashtable<String, String>();
	env.put(Context.INITIAL_CONTEXT_FACTORY,
			"dazzle.jndi.testing.spi.DazzleContextFactory");
	env.put(Context.OBJECT_FACTORIES,
			"org.apache.harmony.jndi.tests.javax.naming.spi.news.newsURLContextFactory");

	Object obj = NamingManager.getObjectInstance(null, null, null, env);
	assertNull(obj);

	obj = NamingManager.getObjectInstance(env, null, null, env);
	assertSame(env, obj);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:NamingManagerTest.java

示例13: lookup

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
@Override
public Object lookup(Name name) throws NamingException {
	if (name.isEmpty())
		return cloneCtx();

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter == null)
			throw new NameNotFoundException(name + " not found");

		try {
			return NamingManager.getObjectInstance(inter, new CompositeName().add(atom), this, iEnv);
		} catch (Exception e) {
			NamingException ne = new NamingException("getObjectInstance failed");
			ne.setRootCause(e);
			throw ne;
		}
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		return ((Context) inter).lookup(nm.getSuffix(1));
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:28,代碼來源:LocalContext.java

示例14: next

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
public Object next() throws NamingException {
	String name = (String) iNames.nextElement();
	Object obj = iBindings.get(name);

	try {
		obj = NamingManager.getObjectInstance(obj, new CompositeName().add(name), LocalContext.this, LocalContext.this.iEnv);
	} catch (Exception e) {
		NamingException ne = new NamingException("getObjectInstance failed");
		ne.setRootCause(e);
		throw ne;
	}

	return new Binding(name, obj);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:15,代碼來源:LocalContext.java

示例15: lookup

import javax.naming.spi.NamingManager; //導入方法依賴的package包/類
/**
 * Lookup an object in the default initial context
 * @param context The context to use
 * @param name the name to lookup
 * @param clazz the expected type
 * @return the object
 * @throws Exception for any error
 */
public static <T> T lookup(final Context context, final String name, final Class<T> clazz) throws Exception
{
  Object object = context.lookup(name);

  if (object instanceof Reference)
    {
   return (T)NamingManager.getObjectInstance(object, null, null, null);
    }

  return clazz.cast(object);

}
 
開發者ID:leogsilva,項目名稱:rabbitmq-resource-adapter,代碼行數:21,代碼來源:Util.java


注:本文中的javax.naming.spi.NamingManager.getObjectInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。