我有一些遗留代码,我现在正试图在Spring下重用.这段代码深深地嵌套在其他代码中,因此重新设计并不常用,在许多情况下都会调用,其中只有一些是通过Spring实现的.我想做的是使用Spring事务,如果已经启动了; 否则,继续使用现有(传统)数据库连接机制.我们的第一个想法是让我们的遗产类成为一个bean并使用注入TransactionPlatformManager,但似乎没有任何方法与我们的情况密切相关.一些研究表明Spring有一个叫做TransactionSynchronizationManager静态方法的类isActualTransactionActive().我的测试表明这种方法是检测Spring事务是否处于活动状态的可靠方法:
@Transactional注释的Spring服务调用时,它返回false@Transactional,它返回true我的问题:有没有更好的方法来检测交易是否有效?
是否可以使用swagger作为使用OAuth2的API的文档/测试工具?我没有在招摇网站(或其他任何地方)看到任何东西.我见过的每种用法都使用API密钥,HTTP基本或cookie.
是否有用于记录AngularJS指令的临时标准或工具?我们明确地构建了可重用功能的部分,因此我们应该能够将它们的接口交给开发人员.我见过几件事:
人们找到了一些更好的方法吗?
我试图在Swagger编辑器中获得一个多行文字(顺便说一下,这是一个很棒的工具!).
post:
summary: Translate one or more identifiers
description: |
Translate one or more identifiers for one entity into the
identifiers of another entity. Translate one or more
identifiers for one entity into the identifiers of another entity.
consumes:
- application/json
Run Code Online (Sandbox Code Playgroud)
我试过了| 和>,具有不同的结尾(增加缩进与空行),以及我能想到的每一种方式,但它总是给出相同的错误:
YAML Syntax Error
Can not read a block mapping entry; a multiline key may not be an implicit
key at line 24, column 15: consumes: ^
Run Code Online (Sandbox Code Playgroud)
我看到JS-YAML的错误表明问题是最终的Windows风格的换行符,我知道HTML textareas可以创建.这是我第一次真正使用YAML,那么只是我做错了什么,或者是Swagger编辑器中的错误?
我已经看到很多地方使用相同的示例代码显示启用Kafka客户端身份验证:
即:
ssl.keystore.location=/var/private/ssl/kafka.client.keystore.jks
ssl.keystore.password=test1234
ssl.key.password=test1234
Run Code Online (Sandbox Code Playgroud)
我的问题是,客户端如何指定要使用的密钥库中的特定密钥?在其他地方我看到JKS密钥库讨论过,密钥是使用别名指定的.我唯一能想到的是:
我想在我的API中实现"获取更改值"功能.例如,假设我有以下REST API调用:
GET /ws/school/7/student
Run Code Online (Sandbox Code Playgroud)
这让所有学生都在学校#7.不幸的是,这可能很多.因此,我想修改API以仅返回自特定时间以来已修改的学生记录.(用例是夜间进程从另一个系统运行,将所有学生从我的系统中拉到他们的系统.)
我看到http://blog.mugunthkumar.com/articles/restful-api-server-doing-it-the-right-way-part-2/建议使用if-modified-since标头并返回如下表示:
我理解他想做什么,但这似乎是错误的方法.If-Modified-Since标题的定义(http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24)说:
If-Modified-Since请求标头字段与方法一起使用以使其成为条件:如果请求的变体自该字段中指定的时间以来未被修改,则不会从服务器返回实体; 相反,将返回304(未修改)响应,而不返回任何消息体.
这对我来说似乎不对.我们不会返回RFC所示的表示或304,而是一些混合.看起来客户端代码(或者更糟糕的是,服务器和客户端之间的Web缓存)可能会错误地解释其含义并替换本地缓存值,而它应该只是更新它.
那么,有两个问题:
我试图找出涉及Spring Security和SAML的问题.我们正在尝试使用Spring Security(spring-security-core-3.1.1.RELEASE.jar)和SAML(spring-security-saml2-core-1.0.0-RC1-SNAPSHOT.jar)来修改我们的产品SAML SP.编辑:这是我的安全相关上下文xml的(我认为!)相关部分.如您所见,它与此示例XML几乎完全相同.
<!-- Entry point to initialize authentication, default values taken from properties file -->
<bean id="samlEntryPoint" class="com.myproduct.samlsp.impl.PSSAMLEntryPoint">
<property name="defaultProfileOptions">
<bean class="org.springframework.security.saml.websso.WebSSOProfileOptions">
<property name="includeScoping" value="false"/>
</bean>
</property>
</bean>
<!-- Unsecured pages -->
<security:http security="none" pattern="/saml/web/**"/>
<security:http security="none" pattern="/logout.jsp"/>
<security:http security="none" pattern="/favicon.ico"/>
<security:http security="none" pattern="/images/**"/>
<security:http security="none" pattern="/scripts/**"/>
<security:http security="none" pattern="/flash/**"/>
<security:http security="none" pattern="/loggedout.html"/>
<!-- Secured pages -->
<security:http entry-point-ref="samlEntryPoint">
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY"/>
<security:custom-filter before="FIRST" ref="metadataGeneratorFilter"/>
<security:custom-filter after="BASIC_AUTH_FILTER" ref="samlFilter"/>
</security:http>
<!-- IDP Discovery Service -->
<bean id="samlIDPDiscovery" …Run Code Online (Sandbox Code Playgroud) 我想在搜索 WordPress 结果页面上添加一些自定义条件并执行一些其他操作。因此,我\xe2\x80\x99m 检查 is_search() 的值,以确保我\xe2\x80\x99m 仅在正确的时间应用条件。所以在我的子主题的functions.php中我输入:
\n\nif (is_search()) {\n ...\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但这总是返回 false,即使使用像http://mysite/?s=something 这样的url并且正在使用我的主题的 search.php 模板!从functions.php调用是无效的,还是我误解了这个函数的目的?
\n\n就此而言,看看https://wphierarchy.com上提供的模板层次结构,WP 如何知道它\xe2\x80\x99 是搜索结果页面?它如何知道沿着“搜索结果”路径继续前进?我\xe2\x80\x99已经花了一些时间仔细阅读源代码,但还没有\xe2\x80\x99能够找到正确的位置。
\n我需要在http响应返回后在指令中执行链接功能.这个想法是这样的:
<input type="text" my-field>
<script>
angular.module("mine")
.controller ('myCtrl', function ($scope) {
$http.get("/my/service").success(function (data, status, headers, config) {
// OK, done with the query... now I know my field name to bind to. Somehow
// I have to get it down to the link function below...
});
})
.directive ('myField', function ($compile) {
return {
link: function (scope, element, attrs) {
var my_field = attrs.myField;
element.removeAttr('my-field');
// Somehow figure out the field here in ngFieldSpec
element.attr('ng-model', ngFieldSpec);
$compile(element)(scope);
};
});
</script> …Run Code Online (Sandbox Code Playgroud) angularjs ×2
spring ×2
swagger ×2
apache-kafka ×1
indentation ×1
keystore ×1
rest ×1
saml-2.0 ×1
spring-saml ×1
ssl ×1
transactions ×1
wordpress ×1
yaml ×1