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


Java CompositeName類代碼示例

本文整理匯總了Java中javax.naming.CompositeName的典型用法代碼示例。如果您正苦於以下問題:Java CompositeName類的具體用法?Java CompositeName怎麽用?Java CompositeName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: doGet

import javax.naming.CompositeName; //導入依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain;UTF-8");
    PrintWriter out = resp.getWriter();

    try {
        Context initCtx = new InitialContext();

        Boolean b1 = (Boolean) initCtx.lookup(JNDI_NAME);
        Boolean b2 = (Boolean) initCtx.lookup(
                new CompositeName(JNDI_NAME));

        out.print(b1);
        out.print(b2);

    } catch (NamingException ne) {
        throw new ServletException(ne);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:22,代碼來源:TestNamingContext.java

示例2: bind

import javax.naming.CompositeName; //導入依賴的package包/類
@Override
public void bind(Name name, Object obj) throws NamingException {
	if (name.isEmpty()) {
		throw new InvalidNameException("Cannot bind empty name");
	}

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

	if (nm.size() == 1) {
		if (inter != null)
			throw new NameAlreadyBoundException("Use rebind to override");

		obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);

		iBindings.put(atom, obj);
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

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

示例3: rebind

import javax.naming.CompositeName; //導入依賴的package包/類
@Override
public void rebind(Name name, Object obj) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot bind empty name");

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

	if (nm.size() == 1) {
		obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);

		iBindings.put(atom, obj);
	} else {
		Object inter = iBindings.get(atom);
		
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

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

示例4: testPropertyValue_Serializable

import javax.naming.CompositeName; //導入依賴的package包/類
@Test
public void testPropertyValue_Serializable() throws Exception
{
    for (int i = 0; i < 100; i++)
    {
        // Choose a type that implements equals and hashCode but will not be recognised
        runPropertyValueTest(new CompositeName("Name-"+i), false);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:10,代碼來源:PropertyValueDAOTest.java

示例5: getDistinguishedName

import javax.naming.CompositeName; //導入依賴的package包/類
/**
 * Returns the distinguished name of a search result.
 *
 * @param context Our DirContext
 * @param base The base DN
 * @param result The search result
 * @return String containing the distinguished name
 */
protected String getDistinguishedName(DirContext context, String base, SearchResult result)
    throws NamingException {
    // Get the entry's distinguished name
    NameParser parser = context.getNameParser("");
    Name contextName = parser.parse(context.getNameInNamespace());
    Name baseName = parser.parse(base);

    // Bugzilla 32269
    Name entryName = parser.parse(new CompositeName(result.getName()).get(0));

    Name name = contextName.addAll(baseName);
    name = name.addAll(entryName);
    return name.toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:JNDIRealm.java

示例6: getMyComponents

import javax.naming.CompositeName; //導入依賴的package包/類
protected Name getMyComponents(Name name) throws NamingException {
	if (name instanceof CompositeName) {
		if (name.size() > 1)
			throw new InvalidNameException(name.toString() + " has more components than namespace can handle");
		return parse(name.get(0));
	} else {
		return name;
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:10,代碼來源:LocalContext.java

示例7: lookup

import javax.naming.CompositeName; //導入依賴的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

示例8: next

import javax.naming.CompositeName; //導入依賴的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

示例9: getTargetContext

import javax.naming.CompositeName; //導入依賴的package包/類
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:36,代碼來源:ContinuationDirContext.java

示例10: ResolveResult

import javax.naming.CompositeName; //導入依賴的package包/類
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:ResolveResult.java

示例11: appendRemainingComponent

import javax.naming.CompositeName; //導入依賴的package包/類
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:ResolveResult.java

示例12: testPropertySerializableValue

import javax.naming.CompositeName; //導入依賴的package包/類
@Test
public void testPropertySerializableValue() throws Exception
{
    final Serializable serializableValue = new CompositeName("123");
    RetryingTransactionCallback<Pair<Long, Serializable>> createValueCallback = new RetryingTransactionCallback<Pair<Long, Serializable>>()
    {
        public Pair<Long, Serializable> execute() throws Throwable
        {
            return propertyValueDAO.createPropertySerializableValue(serializableValue);
        }
    };
    final Pair<Long, Serializable> entityPair = txnHelper.doInTransaction(createValueCallback, false);
    assertNotNull(entityPair);
    assertEquals(serializableValue, entityPair.getSecond());
    
    RetryingTransactionCallback<Pair<Long, Serializable>> getValueCallback = new RetryingTransactionCallback<Pair<Long, Serializable>>()
    {
        public Pair<Long, Serializable> execute() throws Throwable
        {
            return propertyValueDAO.getPropertySerializableValueById(entityPair.getFirst());
        }
    };
    final Pair<Long, Serializable> entityPairCheck = txnHelper.doInTransaction(getValueCallback, false);
    assertNotNull(entityPairCheck);
    assertEquals(entityPair.getFirst(), entityPairCheck.getFirst());
    assertEquals(entityPair, entityPairCheck);
    
    // Check that we can persist and retrieve byte[] as a Serializable
    final Serializable bytes = (Serializable) new byte[] {1, 2, 3};
    RetryingTransactionCallback<Pair<Long, Void>> testBytesCallback = new RetryingTransactionCallback<Pair<Long, Void>>()
    {
        public Pair<Long, Void> execute() throws Throwable
        {
            Long id = propertyValueDAO.createPropertySerializableValue(bytes).getFirst();
            Serializable check = propertyValueDAO.getPropertySerializableValueById(id).getSecond();
            assertNotNull(check);
            assertTrue(check instanceof byte[]);
            Arrays.equals((byte[])bytes, (byte[])check);
            return null;
        }
    };
    txnHelper.doInTransaction(testBytesCallback, false);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:44,代碼來源:PropertyValueDAOTest.java

示例13: unbind

import javax.naming.CompositeName; //導入依賴的package包/類
@Override
public void unbind(String name) throws NamingException {
	unbind(new CompositeName(name));
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:5,代碼來源:LocalContext.java

示例14: rename

import javax.naming.CompositeName; //導入依賴的package包/類
@Override
public void rename(String oldname, String newname) throws NamingException {
	rename(new CompositeName(oldname), new CompositeName(newname));
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:5,代碼來源:LocalContext.java

示例15: list

import javax.naming.CompositeName; //導入依賴的package包/類
@Override
public NamingEnumeration list(String name) throws NamingException {
	return list(new CompositeName(name));
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:5,代碼來源:LocalContext.java


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