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


Java NamingException類代碼示例

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


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

示例1: jndiDataSource

import javax.naming.NamingException; //導入依賴的package包/類
@Bean(destroyMethod="")
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
    JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
    String jndiName = "java:comp/env/" + env.getProperty("sta.datasource.name", "jdbc/sensorThings");
    bean.setJndiName(jndiName);
    bean.setProxyInterface(DataSource.class);
    bean.setLookupOnStartup(false);
    bean.afterPropertiesSet();
    return (DataSource)bean.getObject();
}
 
開發者ID:kinota,項目名稱:kinota-server,代碼行數:11,代碼來源:Application.java

示例2: main

import javax.naming.NamingException; //導入依賴的package包/類
public static void main(String[] args) throws NamingException {
	checkArgs(args);
	
	// Option is to use the WF context with no properties, this is not working because of JBEAP-xxxx at this moment
	InitialContext ic = new WildFlyInitialContext();
	
	Simple proxy = (Simple) ic.lookup("ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName());
	
	try {
		if(proxy.checkApplicationUser("admin")) {
			log.info("Expected 'admin'");
		} else {
			log.severe("Unexpected user, see server.log");
		}
	} catch (EJBException e) {
		throw e;
	}
}
 
開發者ID:wfink,項目名稱:jboss-eap7.1-playground,代碼行數:19,代碼來源:WildFlyICConfigClient.java

示例3: getAttributeValue

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the required value
 *
 * @exception NamingException if a directory server error occurs
 */
private String getAttributeValue(String attrId, Attributes attrs)
    throws NamingException {

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving attribute " + attrId);

    if (attrId == null || attrs == null)
        return null;

    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return null;
    Object value = attr.get();
    if (value == null)
        return null;
    String valueString = null;
    if (value instanceof byte[])
        valueString = new String((byte[]) value);
    else
        valueString = value.toString();

    return valueString;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:32,代碼來源:JNDIRealm.java

示例4: getName

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Get name.
 * 
 * @return Name value
 */
public String getName() {
	if (name != null)
		return name;
	if (attributes != null) {
		Attribute attribute = attributes.get(NAME);
		if (attribute != null) {
			try {
				name = attribute.get().toString();
			} catch (NamingException e) {
				// No value for the attribute
			}
		}
	}
	return name;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:21,代碼來源:ResourceAttributes.java

示例5: main

import javax.naming.NamingException; //導入依賴的package包/類
public static void main(String[] args) throws NamingException {
	checkArgs(args);
	
	Properties p = new Properties();
	
	p.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
	p.put(Context.PROVIDER_URL, "http-remoting://localhost:9080");
	
	p.put(Context.SECURITY_PRINCIPAL, "delegateUser");
	p.put(Context.SECURITY_CREDENTIALS, "delegateUser");
	InitialContext ic = new InitialContext(p);
	
	DelegateROC proxy = (DelegateROC) ic.lookup("ejb:EAP71-PLAYGROUND-MainServer-rocApp/ejb/DelegateROCBean!" + DelegateROC.class.getName());
	proxy.checkTransactionStickyness();
	
	// ic.close();  // not longer necessary
}
 
開發者ID:wfink,項目名稱:jboss-eap7.1-playground,代碼行數:18,代碼來源:CheckDelegateTxROCClient.java

示例6: findRMIServer

import javax.naming.NamingException; //導入依賴的package包/類
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:27,代碼來源:RMIConnector.java

示例7: getETag

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Get ETag.
 * 
 * @param strong If true, the strong ETag will be returned
 * @return ETag
 */
public String getETag(boolean strong) {
    String result = null;
    if (attributes != null) {
        Attribute attribute = attributes.get(ETAG);
        if (attribute != null) {
            try {
                result = attribute.get().toString();
            } catch (NamingException e) {
                ; // No value for the attribute
            }
        }
    }
    if (strong) {
        // The strong ETag must always be calculated by the resources
        result = strongETag;
    } else {
        // The weakETag is contentLenght + lastModified
        if (weakETag == null) {
            weakETag = "W/\"" + getContentLength() + "-" 
                + getLastModified() + "\"";
        }
        result = weakETag;
    }
    return result;
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:32,代碼來源:ResourceAttributes.java

示例8: getUserIdentity

import javax.naming.NamingException; //導入依賴的package包/類
private String getUserIdentity(final DirContextOperations ctx) {
    final String identity;

    if (useDnForUserIdentity) {
        identity = ctx.getDn().toString();
    } else {
        final Attribute attributeName = ctx.getAttributes().get(userIdentityAttribute);
        if (attributeName == null) {
            throw new AuthorizationAccessException("User identity attribute [" + userIdentityAttribute + "] does not exist.");
        }

        try {
            identity = (String) attributeName.get();
        } catch (NamingException e) {
            throw new AuthorizationAccessException("Error while retrieving user name attribute [" + userIdentityAttribute + "].");
        }
    }

    return IdentityMappingUtil.mapIdentity(identity, identityMappings);
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:21,代碼來源:LdapUserGroupProvider.java

示例9: restoreEnvironmentParameter

import javax.naming.NamingException; //導入依賴的package包/類
private void restoreEnvironmentParameter(DirContext context, String parameterName,
		Hashtable<?, ?> preservedEnvironment) {
	try {
		context.removeFromEnvironment(parameterName);
		if (preservedEnvironment != null && preservedEnvironment.containsKey(parameterName)) {
			context.addToEnvironment(parameterName, preservedEnvironment.get(parameterName));
		}
	} catch (NamingException e) {
		// Ignore
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:12,代碼來源:JNDIRealm.java

示例10: defineTriggerExecutionSpecificPoint

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Defines the Administration point and administrative role for the TriggerExecution specific point
 * @param apCtx The administrative point context
 * @throws NamingException If the operation failed
 */
public static void defineTriggerExecutionSpecificPoint( LdapContext apCtx ) throws NamingException
{
    Attributes ap = apCtx.getAttributes( "", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
    Attribute administrativeRole = ap.get( SchemaConstants.ADMINISTRATIVE_ROLE_AT );
    
    if ( administrativeRole == null
        || !AttributeUtils.containsValueCaseIgnore( administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA ) )
    {
        Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT,
            SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true );
        apCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
    }
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:19,代碼來源:TriggerUtils.java

示例11: lookup

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Retrieves the named object.
 * 
 * @param name the name of the object to look up
 * @return the object bound to name
 * @exception NamingException if a naming exception is encountered
 */
public Object lookup(String name)
    throws NamingException {
    // Strip the URL header
    // Find the appropriate NamingContext according to the current bindings
    // Execute the lookup on that context
    return getBoundContext().lookup(parseName(name));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:SelectorContext.java

示例12: getEJB

import javax.naming.NamingException; //導入依賴的package包/類
protected <T> T getEJB(Class<T> klass){
    try {
        return (T) ctx.lookup("java:global/classes/"+klass.getSimpleName()+"!"+klass.getName());
    } catch (NamingException e) {
        return null;
    }
}
 
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:8,代碼來源:TopUsersTest.java

示例13: removeResource

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Set the specified resources in the naming context.
 */
public void removeResource(String name) {

    try {
        envCtx.unbind(name);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.unbindFailed", e));
    }

    ObjectName on = objectNames.get(name);
    if (on != null) {
        Registry.getRegistry(null, null).unregisterComponent(on);
    }

}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:18,代碼來源:NamingContextListener.java

示例14: getReference

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Retrieves the Reference of this object.
 *
 * @return The non-null Reference of this object.
 * @exception NamingException If a naming exception was encountered
 *          while retrieving the reference.
 */
public Reference getReference() throws NamingException {
    String    cname = "org.hsqldb.jdbc.JDBCDataSourceFactory";
    Reference ref   = new Reference(getClass().getName(), cname, null);

    ref.add(new StringRefAddr("database", source.getDatabase()));
    ref.add(new StringRefAddr("user", source.getUser()));
    ref.add(new StringRefAddr("password", source.password));
    ref.add(new StringRefAddr("loginTimeout",
                              Integer.toString(source.loginTimeout)));
    ref.add(new StringRefAddr("poolSize", Integer.toString(connections.length)));

    return ref;
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:21,代碼來源:JDBCPool.java

示例15: checkWritable

import javax.naming.NamingException; //導入依賴的package包/類
/**
 * Throws a naming exception is Context is not writable.
 */
protected boolean checkWritable() throws NamingException {
	if (isWritable()) {
		return true;
	} else {
		if (exceptionOnFailedWrite) {
			throw new javax.naming.OperationNotSupportedException(sm.getString("namingContext.readOnly"));
		}
	}
	return false;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:14,代碼來源:NamingContext.java


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