【发布时间】:2019-10-27 03:29:13
【问题描述】:
Wildfly 开发人员指南解释了 here 如何使用 Wildfly 特定属性设置 InitialContext。
关于“Scoped EJB Client contexts”的部分outlines,您也可以将这些属性传递给InitialContext:
Properties jndiPropsL = new Properties();
jndiPropsL.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiPropsL.setProperty("endpoint.name", "client-endpoint");
jndiPropsL.setProperty("org.jboss.ejb.client.scoped.context", "true");
jndiPropsL.setProperty("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
jndiPropsL.setProperty("remote.connections", "default");
jndiPropsL.setProperty("remote.connection.default.host", jbossHost);
jndiPropsL.setProperty("remote.connection.default.port", remotingPort);
jndiPropsL.setProperty("remote.connection.default.protocol", "http-remoting");
jndiPropsL.setProperty("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
jndiPropsL.setProperty("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
与此相反,Wildfly 安全指南解释了如何设置“安全”的 EJB 客户端连接:
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080");
InitialContext context = new InitialContext(properties);
凭据通过wildfly-config.xml 文件传递。
如果我想要两个文档中的功能,即“安全”连接和范围上下文,我必须配置什么?我是否只需要提供两组属性,然后将主机和端口设置两次?
【问题讨论】: