好吧,这里可能是一个天真的问题.我有一项服务需要登录到多个网络设备,在每个设备上运行命令并收集结果.为了提高速度,我需要同时访问它们并在完成后使用结果,而不是按顺序收集每个设备上的信息.
使用Spring框架和Jsch,我可以很容易地正确查询每个设备.我遇到一些困惑的地方是尝试重新连接bean以使用TaskExecutor来实现这一目标.我无法弄清楚如何知道如何知道线程何时完成.
到目前为止我所拥有的是:
public class RemoteCommand {
private String user;
private String host;
private String password;
private String command;
private List<String> commandResults;
private TaskExecutor taskExecutor;
public RemoteCommand(String user, String host, String password, TaskExecutor taskExecutor) {
setUser(user);
setHost(host);
setPassword(password);
setTaskExecutor(taskExecutor);
}
/**
* @param user the user to set
*/
public void setUser(String user) {
this.user = user;
}
/**
* @return the user
*/
public String getUser() {
return user;
}
/**
* @param host the host to set
*/ …Run Code Online (Sandbox Code Playgroud) 我使用Spring Security根据Active Directory服务器对用户进行身份验证.CustomUserContext也会注入ldapAuthenticationProvider bean,以提供对其他LDAP属性的访问.一切都很好.我没有问题从认证用户那里拉出我想要的东西.
我遇到的问题是我想要从登录用户以外的用户的Active Directory服务器中检索一些属性,特别是电子邮件地址.是否可以通过利用我已有的功能来实现这一点,或者我唯一的选择是使用完全独立的方法来访问来自不同用户的LDAP属性?
[编辑] 配置如下
安全-config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://xxxx.xxxx.xxx:389" />
<property name="base" value="dc=corp,dc=global,dc=xxxxx,dc=com" />
<property name="userDn" value="CN=lna.authquery,OU=LDAPGroups,OU=NorthAmerica,DC=corp,DC=global,DC=xxxxx,DC=com" />
<property name="password" value="xxxxxxx" />
<property name="pooled" value="true" />
<!-- AD Specific Setting for avoiding the partial exception error -->
<property name="referral" value="follow" />
</bean>
<bean id="ldapAuthenticationProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider" >
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource" />
<property name="userSearch">
<bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0" value="" />
<constructor-arg …Run Code Online (Sandbox Code Playgroud) 我正在重新考虑一些perl代码,而且看起来似乎是这种情况,Perl有一些奇怪的结构,很容易查找.
在这种情况下,我遇到了以下......
$|++;
Run Code Online (Sandbox Code Playgroud)
在"使用"语句之后,这本身就是一条线.
这个命令做什么用的?
我正在使用一个聚合来自多个来源的数据的应用程序.在这种情况下,我需要使用不相关的数据连接到两个不同的Solr服务.为此,我设置了两个不同的数据存储库.我已经定义了bean如下:
@Configuration
@EnableSolrRepositories(basePackages={"foo.utilities.solr.repos.gcr"}, multicoreSupport=true)
public class GcrSolrContext {
@Bean
public SolrClient solrClient() {
return new HttpSolrClient("http://foo:8086/solr/gcr");
}
@Bean
public SolrTemplate solrTemplate(SolrClient client) throws Exception {
return new SolrTemplate(client);
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我无法弄清楚如何拥有两个完全独立的Solr客户端,每个客户端指向不同的URL.由于需要bean solrClient()和solrTemplate(),并且尝试使用不同的URL创建新的Context,只需使用首先创建的bean覆盖solrClient和solrTemplate bean.如果它们是唯一定义的Solr客户端,则每个客户端都可以正常工
简而言之,我如何创建两个(或更多)不同的Spring Solr客户端,每个客户端连接到不同的URL?
附加信息是对评论的回复......
我试图简单地重新创建具有不同配置的SolrContext类.考虑以下内容:
@Configuration
@EnableSolrRepositories(basePackages={"foo.utilities.solr.repos.different"}, multicoreSupport=true)
public class DifferentSolrContext {
@Bean
public SolrClient solrClient() {
return new HttpSolrClient("http://SomethingDifferent:8086/solr/something");
}
@Bean
public SolrTemplate solrTemplate(SolrClient client) throws Exception {
return new SolrTemplate(client);
}
}
Run Code Online (Sandbox Code Playgroud)
这里发生的是@ Bean的solrClient和solrTemplate在启动期间创建bean时被覆盖.
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Overriding bean definition for bean 'solrClient' with a …Run Code Online (Sandbox Code Playgroud)