我正在尝试从我的java应用程序运行ApacheDS实例.
我使用run()ScriptWrapper类的这种方法来执行ApacheDS附带的脚本来运行它:
public class ScriptWrapper implements Serializable {
private String scriptPath;
protected Process run(List<String> params) throws IOException {
LOGGER.debug("Executing script="+scriptPath);
params.add(0, scriptPath);
if(workDir != null) {
return Runtime.getRuntime().exec(params.toArray(new String[params.size()]), envp.toArray(new String[envp.size()]), new File(workDir));
} else {
return Runtime.getRuntime().exec(params.toArray(new String[params.size()]));
}
}
}
Run Code Online (Sandbox Code Playgroud)
但问题是,当这个应用程序运行的tomcat被终止和/或ScriptWrapper被垃圾收集时,ApacheDS的实例也会终止.如何保持活力?
编辑:谢谢你的回答.我已经决定以不同的方式解决这个问题,并通过使用二进制ApacheDS安装的脚本进行守护程序.
我想为Jersey客户端利用设置一个重试处理程序ApacheConnector.我希望这样做,因为我希望它在超时时重试(我的HAProxy会将其切换到另一台服务器).我不知道如何做到这一点Jersey 2.7.
示例代码:
public static void Example() {
ClientConfig clientConfig = new ClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, new PoolingHttpClientConnectionManager());
RequestConfig reqConfig = RequestConfig.custom().build();
clientConfig.property(ApacheClientProperties.REQUEST_CONFIG, reqConfig);
Client client = ClientBuilder.newClient(clientConfig);
WebTarget apiTarget = client.target("http://127.0.0.1/rest");
System.out.println(apiTarget.path(ApiConstant.PING)
.path(ApiConstant.PING1)
.request(MediaType.TEXT_PLAIN)
.get(String.class));
}
Run Code Online (Sandbox Code Playgroud)
如果使用此代码,如果服务器响应错误,我可以设置重试处理程序再次发送请求?可能吗?
我有一个目录,其中包含 20 多个 git 存储库。我必须更改每个文件中的远程原始 URL。我不想手动执行此操作,而是想使用以下命令:
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && git remote set-url origin git@euxxx-x-x-xxx01.xx.xx.xxx.com:/foo/bar/'{}'.git" \;
Run Code Online (Sandbox Code Playgroud)
问题是,括号 {} 被相对路径替换,所以我最终得到以下命令:
git remote set-url origin git@euxxx-x-x-xxx01.xx.xx.xxx.com:/foo/bar/./zaz/repo.git
Run Code Online (Sandbox Code Playgroud)
但我只需要
git remote set-url origin git@euxxx-x-x-xxx01.xx.xx.xxx.com:/foo/bar/repo.git
Run Code Online (Sandbox Code Playgroud)
如何实现这一目标?
我有一些其他开发人员编写的类:
public class ManifestFile implements Serializable {
private final static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
private final static XPathFactory xPathFactory = XPathFactory.newInstance();
private final static DateFormat YYYYMMDD = new SimpleDateFormat("yyyyMMdd");
private final String uuid;
private final Set<File> attachments = new LinkedHashSet<File>();
private final transient ApplicationContext applicationContext = JavaService.INSTANCE.getApplicationContext();
private final transient File attachmentDirectory;
private final Date processAfter = new Date(System.currentTimeMillis() + 3 * 1000 * 60);
{
try {
documentBuilderFactory.setNamespaceAware(true);
final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new StreamSource(getClass().getResourceAsStream("/StrategicEmail5.xsd")));
documentBuilderFactory.setSchema(schema); …Run Code Online (Sandbox Code Playgroud) 我正在努力应对以下异常:
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [update EVALUATION_SHEET set STATUS=?, LAST_EDITED=? where id=?]; SQL state [99999]; error code [17004]; Invalid column type; nested exception is java.sql.SQLException: Invalid column type
Run Code Online (Sandbox Code Playgroud)
这是扔在这里:
jdbcTemplate.update("update E_SHEET set STATUS=?, LAST_EDITED=? where id=?",
new Object[]{eSheet.getStatus().ordinal(), eSheet.getLastEditDate(), eSheet.getId()},
new Object[]{OracleTypes.NUMBER, OracleTypes.TIMESTAMP, OracleTypes.NUMBER});
Run Code Online (Sandbox Code Playgroud)
数据库表创建如下:
create table E_SHEET (
ID number not null unique,
ID_POSITION number not null,
STATUS number default 0 not null,
ID_EXAMINER number not null,
LAST_EDITED timestamp not null);
Run Code Online (Sandbox Code Playgroud)
我不知道是什么导致了这个问题.这个方法:
eSheet.getLastEditDate()
Run Code Online (Sandbox Code Playgroud)
返回java.util.Date对象.我使用Spring JDBC模板和Spring DB以及Oracle DB …
我正在创建一个微服务,负责处理zip和tar文件的归档和解压缩.
我知道微服务应该专注于一个业务功能(BF).但是,当我想到业务功能时,我应该意味着存档和取消归档(1个BF),归档和单独的归档(2个BF)或压缩,去皮,解压缩,解压(4个BF)?
是否有理由更喜欢其中一种选择呢?
java ×4
apache ×1
apacheds ×1
architecture ×1
bash ×1
exec ×1
find ×1
git ×1
jax-rs ×1
jersey-2.0 ×1
oracle12c ×1
soa ×1
spring ×1
spring-boot ×1
spring-jdbc ×1