锘??xml version="1.0" encoding="utf-8" standalone="yes"?>奇米色欧美一区二区三区,亚洲日本在线视频观看,国产精品91在线http://www.aygfsteel.com/paulwong/category/38240.htmlzh-cnWed, 19 Oct 2022 02:41:07 GMTWed, 19 Oct 2022 02:41:07 GMT60MONGODB SPRING DISTINCThttp://www.aygfsteel.com/paulwong/archive/2022/10/18/450835.htmlpaulwongpaulwongTue, 18 Oct 2022 02:22:00 GMThttp://www.aygfsteel.com/paulwong/archive/2022/10/18/450835.htmlhttp://www.aygfsteel.com/paulwong/comments/450835.htmlhttp://www.aygfsteel.com/paulwong/archive/2022/10/18/450835.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/450835.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/450835.html
    private boolean needReorderCheck(String requestId) {
        boolean result = false;
//        try(MongoCursor<String> mongoCursor = 
//                mongoTemplate.getCollection(mongoTemplate.getCollectionName(AccountNumProductLineIndex.class))
//                             .distinct(KEY, Filters.eq(REQUEST_ID, requestId), String.class)
//                             .iterator()
//                )
        try(MongoCursor<Document> mongoCursor = 
                mongoTemplate.getCollection(mongoTemplate.getCollectionName(AccountNumProductLineIndex.class))
                             .aggregate(
                                 Arrays.asList(
                                    Aggregates.project(
                                                    Projections.fields(
                                                                    Projections.excludeId(),
                                                                   Projections.include(KEY),
                                                                   Projections.include(REQUEST_ID)
                                                                )
                                               ),
                                    Aggregates.match(Filters.eq(REQUEST_ID, requestId)),
                                    Aggregates.group("$" + KEY)
                                 )
                              )
                             .allowDiskUse(true)
                             .iterator();
        )
        {
            String key = null;
            boolean breakMe = false;
            LOGGER.info("needReorderCheck.key --> start");
            while(mongoCursor.hasNext()) {
                if(breakMe) {
                    mongoCursor.close();
                    break;
                }
                Document keyDocument = mongoCursor.next();
                key = keyDocument.getString("_id");
//                key = mongoCursor.next().getString(KEY);
//                LOGGER.info("needReorderCheck.keyDocument --> {}, key --> {}", keyDocument, key);
                try(MongoCursor<Document> indexMongoCursor = 
                        mongoTemplate.getCollection(AccountNumProductLineIndex.COLLECTION_NAME)
                                        .find(Filters.and(Filters.eq(REQUEST_ID, requestId), Filters.eq(KEY, key)))
                                        .iterator()
                )
                {
                    int preIndex = -1, currentIndex = -1;
                    Document preIndexDocument = null, currentIndexDocument;
                    while(indexMongoCursor.hasNext()) {
                        currentIndexDocument = indexMongoCursor.next();
//                        System.out.println(currentIndexDocument.toJson());
                        if(preIndexDocument != null) {
                             currentIndex = currentIndexDocument.getInteger(INDEX);
                             preIndex = preIndexDocument.getInteger(INDEX);
                             if(currentIndex - preIndex > 1) {
                                indexMongoCursor.close();
                                breakMe = true;
                                result = true;
                                break;
                            }
                        }
                        preIndexDocument = currentIndexDocument;
                    }
                }
            }
        }
        
        return result;
    }



paulwong 2022-10-18 10:22 鍙戣〃璇勮
]]>
Downloading Large Files using Spring WebClienthttp://www.aygfsteel.com/paulwong/archive/2022/09/22/450822.htmlpaulwongpaulwongThu, 22 Sep 2022 05:14:00 GMThttp://www.aygfsteel.com/paulwong/archive/2022/09/22/450822.htmlhttp://www.aygfsteel.com/paulwong/comments/450822.htmlhttp://www.aygfsteel.com/paulwong/archive/2022/09/22/450822.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/450822.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/450822.htmlhttps://www.amitph.com/spring-webclient-large-file-download/

https://github.com/amitrp/spring-examples/blob/main/spring-webflux-webclient/src/main/java/com/amitph/spring/webclients/service/FileDownloaderWebClientService.java

import lombok.RequiredArgsConstructor;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Objects;

@Service
@RequiredArgsConstructor
public class FileDownloaderWebClientService {
    private final WebClient webClient;

    /**
     * Reads the complete file in-memory. Thus, only useful for very large file
     
*/
    public void downloadUsingByteArray(Path destination) throws IOException {
        Mono<byte[]> monoContents = webClient
                .get()
                .uri("/largefiles/1")
                .retrieve()
                .bodyToMono(byte[].class);

        Files.write(destination, Objects.requireNonNull(monoContents.share().block()),
                StandardOpenOption.CREATE);
    }

    /**
     * Reading file using Mono will try to fit the entire file into the DataBuffer.
     * Results in exception when the file is larger than the DataBuffer capacity.
     
*/
    public void downloadUsingMono(Path destination) {
        Mono<DataBuffer> dataBuffer = webClient
                .get()
                .uri("/largefiles/1")
                .retrieve()
                .bodyToMono(DataBuffer.class);

        DataBufferUtils.write(dataBuffer, destination,
                StandardOpenOption.CREATE)
                .share().block();
    }

    /**
     * Having using Flux we can download files of any size safely.
     * Optionally, we can configure DataBuffer capacity for better memory utilization.
     
*/
    public void downloadUsingFlux(Path destination) {
        Flux<DataBuffer> dataBuffer = webClient
                .get()
                .uri("/largefiles/1")
                .retrieve()
                .bodyToFlux(DataBuffer.class);

        DataBufferUtils.write(dataBuffer, destination,
                StandardOpenOption.CREATE)
                .share().block();
    }
}


paulwong 2022-09-22 13:14 鍙戣〃璇勮
]]>
SPRING INTEGRATION - ENRICHhttp://www.aygfsteel.com/paulwong/archive/2021/09/21/435976.htmlpaulwongpaulwongTue, 21 Sep 2021 05:40:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/09/21/435976.htmlhttp://www.aygfsteel.com/paulwong/comments/435976.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/09/21/435976.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435976.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435976.html
package org.springframework.integration.stackoverflow.enricher;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.Transformers;
import org.springframework.integration.http.dsl.Http;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class SpringIntegrationEnricherApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringIntegrationEnricherApplication.class, args);
    }

    @Bean
    public IntegrationFlow jsonEnricherFlow(RestTemplate restTemplate) {
        return IntegrationFlows.from(Function.class)
                .transform(Transformers.fromJson(Map.class))
                .enrich((enricher) -> enricher
                        .<Map<String, ?>>requestPayload((message) ->
                                ((List<?>) message.getPayload().get("attributeIds"))
                                        .stream()
                                        .map(Object::toString)
                                        .collect(Collectors.joining(",")))
                        .requestSubFlow((subFlow) ->
                                subFlow.handle(
                                        Http.outboundGateway("/attributes?id={ids}", restTemplate)
                                                .httpMethod(HttpMethod.GET)
                                                .expectedResponseType(Map.class)
                                                .uriVariable("ids", "payload")))
                        .propertyExpression("attributes", "payload.attributes"))
                .<Map<String, ?>, Map<String, ?>>transform(
                        (payload) -> {
                            payload.remove("attributeIds");
                            return payload;
                        })
                .transform(Transformers.toJson())
                .get();
    }

}

https://stackoverflow.com/questions/58205432/spring-integration-enrich-transform-message-using-rest-call

https://www.tabnine.com/web/assistant/code/rs/5c781b6ae70f87000197ab9f#L312



paulwong 2021-09-21 13:40 鍙戣〃璇勮
]]>
SRPING鑷甫鐨勪簨浠剁洃鍚満鍒?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/04/09/435851.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 09 Apr 2021 06:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/04/09/435851.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435851.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/04/09/435851.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435851.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435851.html</trackback:ping><description><![CDATA[瀹氫箟涓涓簨浠訛紝鍥燬PRING涓彲浠ユ湁涓嶅悓鐨勪簨浠訛紝闇瑕佸畾涔変竴涓被浠ヤ綔鍖哄垎錛?br /><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> lombok.Getter;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.ApplicationEvent;<br /><br /><br />@Getter<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> JavaStackEvent <span style="color: #0000FF; ">extends</span> ApplicationEvent {<br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Create a new {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> ApplicationEvent}.<br />     *<br />     * </span><span style="color: #808080; ">@param</span><span style="color: #008000; "> source the object on which the event initially occurred or with<br />     *               which the event is associated (never {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> null})<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">public</span> JavaStackEvent(Object source) {<br />        <span style="color: #0000FF; ">super</span>(source);<br />    }<br /><br /><br />}</div><br />瀹氫箟涓涓浜嬩歡瑙傚療鑰咃紝鍗蟲劅鍏磋叮鑰咃細<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> lombok.NonNull;<br /><span style="color: #0000FF; ">import</span> lombok.RequiredArgsConstructor;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.ApplicationListener;<br /><span style="color: #0000FF; ">import</span> org.springframework.scheduling.annotation.Async;<br /><br /><span style="color: #008000; ">/**</span><span style="color: #008000; "><br /> * 瑙傚療鑰咃細璇昏呯矇涓?br /> </span><span style="color: #008000; ">*/</span><br />@RequiredArgsConstructor<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> ReaderListener <span style="color: #0000FF; ">implements</span> ApplicationListener<JavaStackEvent> {<br /><br />    @NonNull<br />    <span style="color: #0000FF; ">private</span> String name;<br /><br />    <span style="color: #0000FF; ">private</span> String article;<br /><br />    @Async<br />    @Override<br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> onApplicationEvent(JavaStackEvent event) {<br />        <span style="color: #008000; ">//</span><span style="color: #008000; "> 鏇存柊鏂囩珷</span><span style="color: #008000; "><br /></span>        updateArticle(event);<br />    }<br /><br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">void</span> updateArticle(JavaStackEvent event) {<br />        <span style="color: #0000FF; ">this</span>.article = (String) event.getSource();<br />        System.out.printf("鎴戞槸璇昏咃細%s錛屾枃绔犲凡鏇存柊涓猴細%s\n", <span style="color: #0000FF; ">this</span>.name, <span style="color: #0000FF; ">this</span>.article);<br />    }<br /><br />}</div><br />娉ㄥ唽鎰熷叴瓚h咃紙灝嗚嚜韜敞鍏PRING瀹瑰櫒鍒欏畬鎴愭敞鍐岋級錛屽茍鍒跺畾鍙戝竷鏈哄埗錛堥氳繃CONTEXT鍙戝竷浜嬩歡錛夛細<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> lombok.extern.slf4j.Slf4j;<br /><span style="color: #0000FF; ">import</span> org.springframework.boot.CommandLineRunner;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.ApplicationContext;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Bean;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Configuration;<br /><br />@Slf4j<br />@Configuration<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> ObserverConfiguration {<br /><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> CommandLineRunner commandLineRunner(ApplicationContext context) {<br />        <span style="color: #0000FF; ">return</span> (args) -> {<br />            log.info("鍙戝竷浜嬩歡錛氫粈涔堟槸瑙傚療鑰呮ā寮忥紵");<br />            context.publishEvent(<span style="color: #0000FF; ">new</span> JavaStackEvent("浠涔堟槸瑙傚療鑰呮ā寮忥紵"));<br />        };<br />    }<br /><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> ReaderListener readerListener1(){<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> ReaderListener("灝忔槑");<br />    }<br /><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> ReaderListener readerListener2(){<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> ReaderListener("灝忓紶");<br />    }<br /><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> ReaderListener readerListener3(){<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> ReaderListener("灝忕埍");<br />    }<br /><br />}</div><img src ="http://www.aygfsteel.com/paulwong/aggbug/435851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-04-09 14:55 <a href="http://www.aygfsteel.com/paulwong/archive/2021/04/09/435851.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>csv 鏂囦歡鎵撳紑涔辯爜錛屾湁鍝簺鏂規硶鍙互瑙e喅錛?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 23 Mar 2021 02:30:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435832.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435832.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435832.html</trackback:ping><description><![CDATA[Excel 鍦ㄨ鍙?csv 鐨勬椂鍊欐槸閫氳繃璇誨彇鏂囦歡澶翠笂鐨?bom 鏉ヨ瘑鍒紪鐮佺殑錛岃繖瀵艱嚧濡傛灉鎴戜滑鐢熸垚 csv 鏂囦歡鐨勫鉤鍙拌緭鍑烘棤 bom 澶寸紪鐮佺殑 csv 鏂囦歡錛堜緥濡?utf-8 錛屽湪鏍囧噯涓粯璁ゆ槸鍙互娌℃湁 bom 澶寸殑錛夛紝Excel 鍙兘鑷姩鎸夌収榛樿緙栫爜璇誨彇錛屼笉涓鑷村氨浼氬嚭鐜頒貢鐮侀棶棰樹簡銆?br /><br />鎺屾彙浜嗚繖鐐圭浉淇′貢鐮佸凡緇忔棤娉曢樆鎸℃垜浠墠榪涚殑姝ヤ紣浜嗭細鍙渶灝嗕笉甯?bom 澶寸紪鐮佺殑 csv 鏂囦歡錛岀敤鏂囨湰緙栬緫鍣紙宸ュ叿闅忔剰錛屾帹鑽?notepad++ 錛夋墦寮騫惰漿鎹負甯?bom 鐨勭紪鐮佸艦寮忥紙鍏蜂綋緙栫爜鏂瑰紡闅忔剰錛夛紝闂瑙e喅銆?br /><br />褰撶劧錛屽鏋滀綘鏄儚鎴戜竴鏍風殑鐮佸啘鍝ュ摜錛屽湪鐢熸垚 csv 鏂囦歡鐨勬椂鍊欏啓鍏?bom 澶存洿鐩存帴鐐癸紝鐢ㄦ埛浼氭劅璋綘鐨勩?br /><br />闄勫綍錛氬浜?utf-8 緙栫爜錛寀nicode 鏍囧噯涓槸娌℃湁 bom 瀹氫箟鐨勶紝寰蔣鍦ㄨ嚜宸辯殑 utf-8 鏍煎紡鐨勬枃鏈枃浠朵箣鍓嶅姞涓婁簡EF BB BF涓変釜瀛楄妭浣滀負璇嗗埆姝ょ紪鐮佺殑 bom 澶達紝榪欎篃瑙i噴浜嗕負鍟ュぇ閮ㄥ垎涔辯爜閮芥槸 utf-8 緙栫爜瀵艱嚧鐨勫師鍥?br /><br />SPRING BATCH涓敓鎴怌SV鏂囦歡鏃剁殑瑙e喅鏂規錛?br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">new</span> FlatFileItemWriterBuilder<T>()<br />      .name(itemWriterName)<br />      .resource(outputResource)<br />      .lineAggregator(lineAggregator)<br />      .headerCallback(<br />      h -> {<br />               System.out.println(header);<br />               h.write('\uFEFF');<span style="color: #008000; ">//</span><span style="color: #008000; ">鍙渶鍔犺繖涓琛?/span><span style="color: #008000; "><br /></span>               h.write(header);<br />           }<br />      )<br />      .build();</div><br /><a target="_blank">https://stackoverflow.com/questions/48952319/send-csv-file-encoded-in-utf-8-with-bom-in-java</a><br /><img src ="http://www.aygfsteel.com/paulwong/aggbug/435832.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-03-23 10:30 <a href="http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>JSR-303 Bean Validation - Date String Validation http://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.htmlpaulwongpaulwongThu, 25 Feb 2021 01:44:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.htmlhttp://www.aygfsteel.com/paulwong/comments/435810.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435810.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435810.html鍏跺疄鍙互鏂板姞涓涓柟娉曡繑鍥濪ate綾誨瀷錛屽啀閰嶅悎@Future@Past 榪涜楠岃瘉銆?br />
@Future(message = "Invalid CN_ID_INFO.EXPIRE_DATE.")
private LocalDate getValidExpireDate() {
    try {
        return LocalDate.parse(this.dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    } catch (Exception e) {
        return null;
    }
}

姝ゆ柟娉曞dateString榪涜瑙i噴錛岃繑鍥濴ocalDate錛屽鏋渄ateString涓虹┖鎴栨牸寮忛敊璇紝鍒欒繑鍥炵┖錛屽啀閰嶅悎@Future 榪涜鏄惁鏈潵鏃ユ湡鐨勯獙璇併?br />


paulwong 2021-02-25 09:44 鍙戣〃璇勮
]]>
JSR-303 Bean Validation - Conditional Validationhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.htmlpaulwongpaulwongThu, 25 Feb 2021 01:24:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.htmlhttp://www.aygfsteel.com/paulwong/comments/435809.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435809.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435809.html榪欑鏂規硶閬垮厤浜嗚嚜瀹氫箟鏍¢獙鍣ㄨ屽鍔犵被銆?br />https://www.chkui.com/article/java/java_bean_validation

@AssertTrue(message = "Missing BANK_CARD_IMG_INFO.IMG")
private Boolean getValidImg() {
    if(YNEnum.Y.code.equals(super.getNeedChecked())) {
            return StringUtils.hasText(this.img);
        }
        return null;//igore checking.
}

榪欎釜鏄綋needChecked涓篩鐨勬椂鍊欐墠鎵ц媯鏌mg鍙橀噺鏄惁涓虹┖銆?br />鏈夊嚑鐐規敞鎰忥細
  1. 鏂規硶鍚嶇О瑕佷互get寮澶?br />
  2. 榪斿洖綾誨瀷鐢˙oolean錛岃屼笉鐢╞oolean
  3. 榪斿洖鍊兼湁涓夌錛歵rue,false,null濡傛灉鏄痭ull鍒欏綋鎴愰氳繃錛屼笌true鐨勭粨鏋滀竴鏍?/li>


paulwong 2021-02-25 09:24 鍙戣〃璇勮
]]>
JSR-303 Bean Validationhttp://www.aygfsteel.com/paulwong/archive/2021/01/28/435786.htmlpaulwongpaulwongThu, 28 Jan 2021 02:35:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/01/28/435786.htmlhttp://www.aygfsteel.com/paulwong/comments/435786.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/01/28/435786.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435786.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435786.html
JSR-303 Bean Validation鍒欐彁渚涗簡榪欐牱鐨勪究鎹楓?br />
鍙鍦↗AVA BEAN涓渶瑕侀獙璇佺殑瀛楁鍔燖NotNull榪欑鏍囩錛岀劧鍚庡湪SERVISE涓殑杈撳叆鍙傛暟涓姞@Valid鏍囩錛屽垯灝辨縺媧婚獙璇佹祦紼嬨?br />涔熷彲浠ョ紪紼嬬殑鏂瑰紡鑷繁楠岃瘉錛?br />
@MessageEndpoint
//@Validated
public class MqMessageCcdValidator {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(MqMessageCcdValidator.class);
    
    @Autowired
    private Validator validator;
    
    @ServiceActivator
    public MqMessage<CcdRequest> validate(/* @Valid */ Message<MqMessage<CcdRequest>> requestMessage) {
        Set<ConstraintViolation<MqMessage<CcdRequest>>> set = validator.validate(requestMessage.getPayload());
        if(CollectionUtils.isNotEmpty(set)) {
            CompositeException compositeException = new CompositeException();
            set.forEach(
                constraintViolation -> {
                                            LOGGER.info("{}", constraintViolation);
                                            ReqInfoValidationException exception =
                                                    new ReqInfoValidationException(constraintViolation.getMessage());
                                            compositeException.addException(exception);
                                       }
            );
            throw new MessageHandlingException(requestMessage, compositeException);
        }
        
        return requestMessage.getPayload();
    }

}

鑷畾涔夐獙璇佽鍒?br />鍙敤鏍囩鏉ュ仛錛屼互涓嬩負楠岃瘉鎵嬫満鍙風殑瑙勫垯錛?br />
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.Pattern;

@Retention(RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
@Constraint(validatedBy = {})
@ReportAsSingleViolation
@Pattern(regexp = "^1[3-9]\\d{9}$")
public @interface ChinaPhone {
    String message() default "Invalid Chinese mobile No.";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
}

濡傛灉姣旇緝澶嶆潅鐨勯獙璇佽鍒欙紝鍒欏弬瑙侊細
https://reflectoring.io/bean-validation-with-spring-boot/#implementing-a-custom-validator

How to use Java Bean Validation in Spring Boot
https://nullbeans.com/how-to-use-java-bean-validation-in-spring-boot/

Complete Guide to Validation With Spring Boot
https://reflectoring.io/bean-validation-with-spring-boot/

Spring JMS Validate Messages using JSR-303 Bean Validation
https://memorynotfound.com/spring-jms-validate-messages-jsr-303-bean-validation/

Spring REST Validation Example
https://mkyong.com/spring-boot/spring-rest-validation-example/

Spring Boot 鏁村悎 Bean Validation 鏍¢獙鏁版嵁

https://blog.csdn.net/wangzhihao1994/article/details/108403732


paulwong 2021-01-28 10:35 鍙戣〃璇勮
]]>
SPRING INTEGRATION HEADER闂http://www.aygfsteel.com/paulwong/archive/2020/10/20/435696.htmlpaulwongpaulwongTue, 20 Oct 2020 06:56:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/10/20/435696.htmlhttp://www.aygfsteel.com/paulwong/comments/435696.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/10/20/435696.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435696.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435696.html
.headerFilter("Api-Key", "Content-Type", "X-Powered-By", "Content-Language", "Transfer-Encoding", "Cache-Control", "Keep-Alive", "Set-Cookie")

https://stackoverflow.com/questions/50608415/cwsia0112e-the-property-name-keep-alive-is-not-a-valid-java-identifier

paulwong 2020-10-20 14:56 鍙戣〃璇勮
]]>
RestTemplate澶勭悊璇鋒眰鐘舵佺爜涓洪潪200鐨勮繑鍥炴暟鎹?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/10/16/435694.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 16 Oct 2020 08:54:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/10/16/435694.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435694.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/10/16/435694.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435694.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435694.html</trackback:ping><description><![CDATA[RestTemplate鏄疭pring鎻愪緵鐨勭敤浜庤闂甊est鏈嶅姟鐨勫鎴風錛?br /><br />RestTemplate鎻愪緵浜嗗縐嶄究鎹瘋闂繙紼婬ttp鏈嶅姟鐨勬柟娉?鑳藉澶уぇ鎻愰珮瀹㈡埛绔殑緙栧啓鏁堢巼銆?br /><br />璋冪敤RestTemplate鐨勯粯璁ゆ瀯閫犲嚱鏁幫紝RestTemplate瀵硅薄鍦ㄥ簳灞傞氳繃浣跨敤java.net鍖呬笅鐨勫疄鐜板垱寤篐TTP 璇鋒眰錛?br /><br />鍙互閫氳繃浣跨敤ClientHttpRequestFactory鎸囧畾涓嶅悓鐨凥TTP璇鋒眰鏂瑰紡銆?br /><br />ClientHttpRequestFactory鎺ュ彛涓昏鎻愪緵浜嗕袱縐嶅疄鐜版柟寮?br /><br />1銆佷竴縐嶆槸SimpleClientHttpRequestFactory錛屼嬌鐢↗2SE鎻愪緵鐨勬柟寮忥紙鏃ava.net鍖呮彁渚涚殑鏂瑰紡錛夊垱寤哄簳灞傜殑Http璇鋒眰榪炴帴銆?br /><br />2銆佷竴縐嶆柟寮忔槸浣跨敤HttpComponentsClientHttpRequestFactory鏂瑰紡錛屽簳灞備嬌鐢℉ttpClient璁塊棶榪滅▼鐨凥ttp鏈嶅姟錛屼嬌鐢℉ttpClient鍙互閰嶇疆榪炴帴姹犲拰璇佷功絳変俊鎭?br /><br />榛樿鐨?RestTemplate 鏈変釜鏈哄埗鏄姹傜姸鎬佺爜闈?00 灝辨姏鍑哄紓甯革紝浼氫腑鏂帴涓嬫潵鐨勬搷浣溿傚鏋滀笉鎯充腑鏂緇撴灉鏁版嵁寰楄В鏋愶紝鍙互閫氳繃瑕嗙洊榛樿鐨?ResponseErrorHandler 錛岃涓嬮潰鐨勭ず渚嬶紝紺轟緥涓殑鏂規硶涓熀鏈兘鏄┖鏂規硶錛屽彧瑕佸hasError淇敼涓嬶紝璁╀粬涓鐩磋繑鍥瀟rue錛屽嵆鏄笉媯鏌ョ姸鎬佺爜鍙婃姏寮傚父浜嗐?br /><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">package</span> com.example.demo.web.config;<br /><br /><span style="color: #0000FF; ">import</span> java.io.IOException;<br /><br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Bean;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Configuration;<br /><span style="color: #0000FF; ">import</span> org.springframework.http.client.ClientHttpRequestFactory;<br /><span style="color: #0000FF; ">import</span> org.springframework.http.client.ClientHttpResponse;<br /><span style="color: #0000FF; ">import</span> org.springframework.http.client.SimpleClientHttpRequestFactory;<br /><span style="color: #0000FF; ">import</span> org.springframework.web.client.ResponseErrorHandler;<br /><span style="color: #0000FF; ">import</span> org.springframework.web.client.RestTemplate;<br /><br />@Configuration<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> RestTemplateConfig {<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> RestTemplate restTemplate(ClientHttpRequestFactory factory) <span style="color: #0000FF; ">throws</span> Exception {<br />        RestTemplate restTemplate = <span style="color: #0000FF; ">new</span> RestTemplate(factory);<br />        ResponseErrorHandler responseErrorHandler = <span style="color: #0000FF; ">new</span> ResponseErrorHandler() {<br />            @Override<br />            <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">boolean</span> hasError(ClientHttpResponse clientHttpResponse) <span style="color: #0000FF; ">throws</span> IOException {<br />                <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">true</span>;<br />            }<br />            @Override<br />            <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> handleError(ClientHttpResponse clientHttpResponse) <span style="color: #0000FF; ">throws</span> IOException {<br />            }<br />        };<br />        restTemplate.setErrorHandler(responseErrorHandler);<br />        <span style="color: #0000FF; ">return</span> restTemplate;<br />    }<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> ClientHttpRequestFactory simpleClientHttpRequestFactory(){<br />        SimpleClientHttpRequestFactory factory = <span style="color: #0000FF; ">new</span> SimpleClientHttpRequestFactory();<br />        <span style="color: #008000; ">//</span><span style="color: #008000; ">璇誨彇瓚呮椂5縐?/span><span style="color: #008000; "><br /></span>        factory.setReadTimeout(5000);<br />        <span style="color: #008000; ">//</span><span style="color: #008000; ">榪炴帴瓚呮椂15縐?/span><span style="color: #008000; "><br /></span>        factory.setConnectTimeout(15000);<br />        <span style="color: #0000FF; ">return</span> factory;<br />    }<br />}</div><br />RestTemppate榪愮敤瀹炰緥<br /><br /><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">package</span> com.example.demo.web.controller;<br /><br /><span style="color: #0000FF; ">import</span> org.slf4j.Logger;<br /><span style="color: #0000FF; ">import</span> org.slf4j.LoggerFactory;<br /><span style="color: #0000FF; ">import</span> org.springframework.beans.factory.annotation.Autowired;<br /><span style="color: #0000FF; ">import</span> org.springframework.http.ResponseEntity;<br /><span style="color: #0000FF; ">import</span> org.springframework.web.bind.annotation.GetMapping;<br /><span style="color: #0000FF; ">import</span> org.springframework.web.bind.annotation.RestController;<br /><span style="color: #0000FF; ">import</span> org.springframework.web.client.RestTemplate;<br /><br /><span style="color: #0000FF; ">import</span> com.example.demo.domain.Book;<br /><br />@RestController<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> TestBookController {<br />    <span style="color: #0000FF; ">private</span> Logger logger = LoggerFactory.getLogger(getClass());<br />    <br />      @Autowired<br />      <span style="color: #0000FF; ">private</span> RestTemplate restTemplate;<br />      <br />      @GetMapping("/testaddbook")<br />      <span style="color: #0000FF; ">public</span> Book testAddBook() {<br />              Book book = <span style="color: #0000FF; ">new</span> Book();<br />              ResponseEntity<Book> responseEntity = restTemplate.postForEntity( "http://localhost:8061/book", book , Book.<span style="color: #0000FF; ">class</span>);<br />              <span style="color: #0000FF; ">return</span> responseEntity.getBody();<br />      }<br /><br />}</div><br />鍏朵粬鏂規硶錛宑atch <span style="font-size: 13px; background-color: #eeeeee;">HttpStatusCodeException </span>, <span style="color: #008000; font-size: 13px; background-color: #eeeeee;">e.getResponseBodyAsString()</span><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">try</span> {<br />    ResponseEntity<Component> response = restTemplate.exchange(webSvcURL,<br />        HttpMethod.POST, <br />        requestEntity,<br />        Component.<span style="color: #0000FF; ">class</span>);<br />} <span style="color: #0000FF; ">catch</span> (HttpStatusCodeException e) {<br />    List<String> customHeader = e.getResponseHeaders().get("x-app-err-id");<br />    String svcErrorMessageID = "";<br />    <span style="color: #0000FF; ">if</span> (customHeader != <span style="color: #0000FF; ">null</span>) {<br />        svcErrorMessageID = customHeader.get(0);                <br />    }<br />    <span style="color: #0000FF; ">throw</span> <span style="color: #0000FF; ">new</span> CustomException(e.getMessage(), e, svcErrorMessageID);<br />    <span style="color: #008000; ">//</span><span style="color: #008000; "> You can get the body too but you will have to deserialize it yourself<br />    </span><span style="color: #008000; ">//</span><span style="color: #008000; "> e.getResponseBodyAsByteArray()<br />    </span><span style="color: #008000; ">//</span><span style="color: #008000; "> e.getResponseBodyAsString()</span><span style="color: #008000; "><br /></span>}</div><br /><a target="_blank">https://stackoverflow.com/questions/7878002/resttemplate-handling-response-headers-body-in-exceptions-restclientexception</a><br /><br /><a target="_blank">https://stackoverflow.com/questions/38093388/spring-resttemplate-exception-handling/51805956#51805956</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/435694.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-10-16 16:54 <a href="http://www.aygfsteel.com/paulwong/archive/2020/10/16/435694.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Error handling in spring integration - How to get all the errors thrown in multiple threads and send them to the error-channelhttp://www.aygfsteel.com/paulwong/archive/2020/10/15/435693.htmlpaulwongpaulwongThu, 15 Oct 2020 11:21:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/10/15/435693.htmlhttp://www.aygfsteel.com/paulwong/comments/435693.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/10/15/435693.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435693.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435693.html
@Bean
public IntegrationFlow provisionUserFlow() {
return
    IntegrationFlows.from("input.channel")
    .publishSubscribeChannel(Executors.newCachedThreadPool(),
        s -> s.applySequence(true)
            .subscribe(f -> f.enrichHeaders(e -> e.header(MessageHeaders.ERROR_CHANNEL, "errorChannel", true))
                .handle(provisionerA, "provision")
                .channel("aggregatorChannel")
            )
            .subscribe(f -> f.enrichHeaders(e -> e.header(MessageHeaders.ERROR_CHANNEL, "errorChannel", true))
                .handle(provisionerB, "provision")
                .channel("aggregatorChannel"))
            )
        .get();
}

@Bean
public IntegrationFlow aggregateFlow() {
    return IntegrationFlows.from("aggregatorChannel")
                    .channel( aggregatorChannel)
                    .aggregate( a -> a.processor( collect, "aggregatingMethod"))
                    .get();
}

@Transformer( inputChannel = "errorChannel", outputChannel = "aggregatorChannel")
public Message<?> errorChannelHandler(ErrorMessage errorMessage) throws RuntimeException {

    Message<?> failedMessage =  ((MessagingException) errorMessage.getPayload()).getFailedMessage();

    Exception exception = (Exception) errorMessage.getPayload();

    return  MessageBuilder.withPayload( exception.getMessage())
                                       .copyHeadersIfAbsent( failedMessage.getHeaders() )
                                       .build();
}


https://stackoverflow.com/q/46495127/11790720



paulwong 2020-10-15 19:21 鍙戣〃璇勮
]]>
SPRING INTEGRATION瀛怓LOWhttp://www.aygfsteel.com/paulwong/archive/2020/10/15/435692.htmlpaulwongpaulwongThu, 15 Oct 2020 03:29:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/10/15/435692.htmlhttp://www.aygfsteel.com/paulwong/comments/435692.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/10/15/435692.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435692.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435692.html split涔嬪悗錛屽彲浠ュ皢message鍒嗙粰涓嶅悓鐨勫瓙flow澶勭悊錛岄厤緗涓嬶細
@Bean
public IntegrationFlow parallelSplitRouteAggregateFlow() {
    return IntegrationFlows
            .from(Http.inboundGateway("/trigger"))
            .handle((p, h) -> Arrays.asList(1, 2, 3))
            .split()
            .channel(MessageChannels.executor(Executors.newCachedThreadPool()))
            .<Integer, Boolean>route(o -> o % 2 == 0, m -> m
                    .subFlowMapping(true, sf -> sf.gateway(oddFlow()))
                    .subFlowMapping(false, sf -> sf.gateway(evenFlow())))
            .aggregate()
            .get();
}

@Bean
public IntegrationFlow oddFlow() {
    return flow -> flow.<Integer>handle((payload, headers) -> "odd");
}

@Bean
public IntegrationFlow evenFlow() {
    return flow -> flow.<Integer>handle((payload, headers) -> "even");
}


https://stackoverflow.com/questions/50121384/spring-integration-parallel-split-route-aggregate-flow-fails-due-to-one-way-mess

paulwong 2020-10-15 11:29 鍙戣〃璇勮
]]>
鎬鏃ф鏋墮泦鍚?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/10/09/435687.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 09 Oct 2020 11:14:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/10/09/435687.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435687.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/10/09/435687.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435687.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435687.html</trackback:ping><description><![CDATA[     鎽樿: 鏈榪戝湪鍏徃鐢↗UP妗嗘灦鍋氶」鐩?鍙戠幇榪欎釜妗嗘灦鏄埆浜哄熀浜嶴pringSide灝佽鐨?鎵浠ユ墦綆楀涔犱笅,SpringSide,鍏朵腑閬囧埌浜嗗緢澶氬潙,鍋氫釜璁板綍,緗戜笂鍏充簬榪欐柟闈㈢殑璧勬枡閮芥湁浜涜佷簡,鑰屼笖SpringSide鏈鏂扮殑鐗堟湰鏄疭pringSide-Utils,鑰佷竴鐐圭殑鐗堟湰涓簐4.2.2.GA,浠ヤ笅鍒嗗埆瀵硅繖涓や釜鐗堟湰鍒嗗埆浠嬬粛涓?涓昏鍐呭鏉ヨ嚜浜庣綉涓娿備竴浜涜祫鏂?Github婧愮爜鍦板潃:  https://gi...  <a href='http://www.aygfsteel.com/paulwong/archive/2020/10/09/435687.html'>闃呰鍏ㄦ枃</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/435687.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-10-09 19:14 <a href="http://www.aygfsteel.com/paulwong/archive/2020/10/09/435687.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Spring Retry妗嗘灦鈥斺旂湅榪欑瘒灝卞浜?/title><link>http://www.aygfsteel.com/paulwong/archive/2020/09/15/435662.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 15 Sep 2020 05:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2020/09/15/435662.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435662.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2020/09/15/435662.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435662.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435662.html</trackback:ping><description><![CDATA[<a target="_blank">https://my.oschina.net/marvelcode/blog/4563352</a><br /><br /><img src ="http://www.aygfsteel.com/paulwong/aggbug/435662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2020-09-15 13:39 <a href="http://www.aygfsteel.com/paulwong/archive/2020/09/15/435662.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>LOGBACK FOR SPRINGhttp://www.aygfsteel.com/paulwong/archive/2019/11/19/434914.htmlpaulwongpaulwongTue, 19 Nov 2019 07:14:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/11/19/434914.htmlhttp://www.aygfsteel.com/paulwong/comments/434914.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/11/19/434914.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434914.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434914.html
鍏朵腑appender鏄敤鏉ヨ緭鍑烘棩蹇楋紝鏈塮ile鍜宑onsole涓や釜瀹炵幇錛宑onsole鍒欐槸鍚戞帶鍒跺彴杈撳嚭鏃ュ織錛岃宖ile鍒欐槸鍚戞枃浠惰緭鍑烘棩蹇椼?br />rolling file appender涓紝鏈塺ollingPolicy鍜宼riggerPolicy涓や釜涓昏灞炴э紝rollingPolicy鏄‘瀹氬浣曞鐞嗘棩蹇楁枃浠訛紝鑰宼riggerPolicy鍒欐槸紜畾浣曟椂澶勭悊鏃ュ織鏂囦歡銆?br />
濡傛灉瑕佷嬌鐢⊿PRING閽堝LOGBACK鐨勪竴浜涘姛鑳斤紝濡俻rofile絳夛紝鍒欒灝唋ogback.xml鐨勯厤緗枃浠跺懡鍚嶄負logback-spring.xml錛屽茍鍦⊿PRING涓厤緗紝logging.config= logback-spring.xml銆?br />
SPRING浼氬皢logging.file銆乴ogging.path榪欎簺閰嶇疆杞垚緋葷粺鍙橀噺LOG_FILE銆丩OG_PATH錛屽彲鍦ㄩ厤緗枃浠朵腑鐩存帴寮曠敤錛屽${LOG_FILE}銆?br />
濡傛灉logback閰嶇疆鏂囦歡瑕丼PRING鐨勫叾浠栧睘鎬э紝鍒欒浣跨敤濡備笅鏍囩錛?br />
<springProperty scope="context" name="logLevel" source="log.level"/>

濡傛灉瑕佷嬌鐢↙OGBACK鐨勪竴浜涘父鐢ㄥ睘鎬э紝鍙紩鍏ワ細
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
濡侰ONSOLE APPENDER錛屾resource鍦╯pring-boot-version.jar涓?br />

=========================================
鐪嬪畬榪欎釜涓嶄細閰嶇疆 logback 錛岃浣犲悆鐡滐紒
https://juejin.im/post/5b51f85c5188251af91a7525

logback瑙f瀽——Appender
https://juejin.im/post/5a39c91cf265da4327185d10

SpringBoot涓璴ogback.xml浣跨敤application.yml涓睘鎬?br />https://www.cnblogs.com/jianliang-Wu/p/8945343.html

springboot浣跨敤logback-spring.xml閰嶇疆璁茶В
https://blog.csdn.net/heguiliang_123/article/details/80296745

Logback閰嶇疆
https://www.cnblogs.com/cjsblog/p/9113131.html

Logback涓浣曡嚜瀹氫箟鐏墊椿鐨勬棩蹇楄繃婊よ鍒?br />https://www.jianshu.com/p/d6360c517264

Spring Boot涓殑鏃ュ織
http://loveshisong.cn/%E7%BC%96%E7%A8%8B%E6%8A%80%E6%9C%AF/2016-11-03-Spring-Boot%E4%B8%AD%E7%9A%84%E6%97%A5%E5%BF%97.html

Spring Boot涓巐ogback鎬葷粨
https://blog.csdn.net/u014527058/article/details/79667458

SpringBoot Logback 閰嶇疆鍙傛暟榪佺Щ鍒伴厤緗腑蹇?Apollo
https://blog.csdn.net/shuaizai88/article/details/83027262


paulwong 2019-11-19 15:14 鍙戣〃璇勮
]]>
spring-loaded鐑儴緗?/title><link>http://www.aygfsteel.com/paulwong/archive/2016/09/11/431784.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Sun, 11 Sep 2016 02:40:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2016/09/11/431784.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/431784.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2016/09/11/431784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/431784.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/431784.html</trackback:ping><description><![CDATA[浠涔堟槸spring-loaded?<br /> <br /> spring-loaded鏄竴涓浜巎vm浠g悊榪愯鏃舵湡鏀瑰彉綾繪枃浠剁殑閲嶈澆錛堥噸鏂板姞杞斤級錛屽畠杞崲綾籰oadtime璁╀粬浠湇浠庡悗閲嶆柊鍔犺澆銆備笉鍍?#8220;鐑唬鐮佹浛鎹?#8221;鍙厑璁鎬竴嬈$畝鍗曠殑鏀瑰彉JVM榪愯(渚嬪鏇存敼鏂規硶浣?spring-loaded鍏佽鎮ㄦ坊鍔?淇敼/鍒犻櫎/瀛楁/鏂規硶鏋勯犲嚱鏁般傛敞閲婄被鍨?鏂規硶/瀛楁/鏋勯犲嚱鏁頒篃鍙互淇敼鍜屽彲浠ユ坊鍔?鍒犻櫎/淇敼鍊肩殑鏋氫婦綾誨瀷銆?br /> <br /> 鏈変粈涔堝ソ澶?<br /> <br /> 寮鍙戞祴璇曢樁孌碉細鑳藉鍦ㄥ惎鍔ㄥ悗鍔ㄦ佹洿鏀逛唬鐮佽皟璇?鏃犻渶閲嶅惎鍑忓皯鍒囨崲debug鏃墮棿錛坧s:瀵逛簬eclipse鑰岃█錛屽湪debug鏃舵湡鍙兘鍋氬埌鍔ㄦ佹洿鏂版柟娉曚綋涓嶈兘澧炲姞錛?br /> 瀵逛簬綰夸笂嫻嬭瘯鍙戝竷闃舵錛?鑳藉鍦ㄥ嚭鐜伴棶棰樺悗鐩存帴鏇挎崲class鏂囦歡鑰屼笉閲嶅惎搴旂敤錛坧s:瀵逛簬澶栭儴鎻愪緵鐨勬湇鍔ar褰㈠紡鍚屾牱鑳藉仛鍒幫級<br /> 鎬庝箞浣跨敤?<br /> <br /> 欏圭洰鍦板潃<br /> <br /> <a target="_blank">https://github.com/spring-projects/spring-loaded</a> <br /><br />絎竴姝ワ細涓嬭澆鏂囦歡<br /><a target="_blank">http://repo.spring.io/release/org/springframework/springloaded/1.2.5.RELEASE/springloaded-1.2.5.RELEASE.jar</a><br /><br />絎簩姝ワ細閰嶇疆jvm鍚姩鍙傛暟<br /><br />eclipse<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->eclipse錛歳un as --> run configurations --> arguments -->> VM arguments<br />-javaagent:E:\repository\org\springframework\spring-load\springloaded-1.2.5.RELEASE.jar <br />-noverify -Dspringloaded=verbose<br />璇︾粏鎻忚堪錛?br />-javaagent: 閰嶇疆java浠g悊浣跨敤涓嬭澆鍚庣殑jar鍖呰礬寰?br />-noverify: 紱佺敤瀛楄妭鐮侀獙璇?br />-Dspringloaded=verbose 鏄劇ずspringloaded鏃剁殑璇︾粏淇℃伅</div><br /><br /><p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: #3d464d; font-family: "Pingfang SC", STHeiti, "Lantinghei SC", "Open Sans", Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; font-size: 16px; line-height: 30px;"><img src="https://cloud.githubusercontent.com/assets/9413389/18079968/ef143758-6ec5-11e6-8a72-ab3cd30b4af9.png" alt="image" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; border: none; margin: auto; max-width: 80%; height: auto;" /></p><h4>java鍛戒護鍚姩</h4><pre css"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; color: #777777; border-radius: 3px; line-height: 1.4; word-wrap: normal; background: #fdf6e3;"><code css"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; display: block; overflow-x: auto; padding: 10px; border-radius: 4px; line-height: 1.4; word-wrap: normal; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">java</span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">-javaagent</span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #cb4b16;">:E</span>:\<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">repository</span>\<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">org</span>\<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">springframework</span>\<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">spring-load</span>\<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">springloaded-1</span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;">.2</span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;">.5</span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;">.RELEASE</span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;">.jar</span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">-noverify</span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">Test</span> 綾諱技 </code></pre><h4>java jar鍖呭姩鎬佹浛鎹?/h4><h5>1.鎵撴垚runnable Jar</h5><h5>2.鍛戒護鍚姩錛?/h5><p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: #3d464d; font-family: "Pingfang SC", STHeiti, "Lantinghei SC", "Open Sans", Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; font-size: 16px; line-height: 30px;">java -javaagent:E:\repository\org\springframework\spring-load\springloaded-1.2.5.RELEASE.jar -noverify -Dspringloaded=watchJars=main.jar main.jar</p><pre java"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; color: #777777; border-radius: 3px; line-height: 1.4; word-wrap: normal; background: #fdf6e3;"><code java"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; display: block; overflow-x: auto; padding: 10px; border-radius: 4px; line-height: 1.4; word-wrap: normal; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #93a1a1;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">/** * 綾籘est.java鐨勫疄鐜版弿榪幫細TODO 綾誨疄鐜版弿榪? * </span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #93a1a1;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;">@author</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"> Administrator 2016騫?鏈?鏃?涓嬪崍4:55:59 */</span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">public</span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">class</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #b58900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">Test</span></span></span> </span>{ <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">public</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">static</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">void</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">main</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">(String[] args)</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">throws</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"> InterruptedException </span></span>{ <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">while</span>(<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">true</span>) { <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">try</span> { println(); Thread.sleep(<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;">1000</span>); } <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">catch</span> (Throwable e) { e.printStackTrace(); } } } <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">public</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">static</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">void</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">println</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">()</span></span></span> </span>{ System.out.println(<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;">"112222221222222"</span>); } } </code></pre><p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: #3d464d; font-family: "Pingfang SC", STHeiti, "Lantinghei SC", "Open Sans", Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; font-size: 16px; line-height: 30px;">鏀瑰彉涓?/p><pre java"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; color: #777777; border-radius: 3px; line-height: 1.4; word-wrap: normal; background: #fdf6e3;"><code java"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; display: block; overflow-x: auto; padding: 10px; border-radius: 4px; line-height: 1.4; word-wrap: normal; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #93a1a1;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">/** * 綾籘est.java鐨勫疄鐜版弿榪幫細TODO 綾誨疄鐜版弿榪? * </span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #93a1a1;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;">@author</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"> Administrator 2016騫?鏈?鏃?涓嬪崍4:55:59 */</span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">public</span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">class</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #b58900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">Test</span></span></span> </span>{ <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">public</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">static</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">void</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">main</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">(String[] args)</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">throws</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"> InterruptedException </span></span>{ <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">while</span>(<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">true</span>) { <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">try</span> { println(); Thread.sleep(<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;">1000</span>); } <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;">catch</span> (Throwable e) { e.printStackTrace(); } } } <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">public</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">static</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #859900;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">void</span></span></span> <span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #268bd2;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">println</span></span></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">()</span></span></span> </span>{ System.out.println(<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #2aa198;">"test replace jar"</span>); } } </code></pre><h5>3.閲嶆柊鎵撳寘鏇挎崲</h5><pre javascript"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; color: #777777; border-radius: 3px; line-height: 1.4; word-wrap: normal; background: #fdf6e3;"><code javascript"="" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; display: block; overflow-x: auto; padding: 10px; border-radius: 4px; line-height: 1.4; word-wrap: normal; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">PS錛氬疄嫻嬪湪<span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: #dc322f;">window</span>涓嬫棤鐢?鎵嬩笂鏃爈inux鏈哄櫒寰呮祴璇?/code></pre><br /><br /><br /><br />1<img src ="http://www.aygfsteel.com/paulwong/aggbug/431784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2016-09-11 10:40 <a href="http://www.aygfsteel.com/paulwong/archive/2016/09/11/431784.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>SPRING MVC鏁村悎NETTYhttp://www.aygfsteel.com/paulwong/archive/2016/04/19/430146.htmlpaulwongpaulwongTue, 19 Apr 2016 05:27:00 GMThttp://www.aygfsteel.com/paulwong/archive/2016/04/19/430146.htmlhttp://www.aygfsteel.com/paulwong/comments/430146.htmlhttp://www.aygfsteel.com/paulwong/archive/2016/04/19/430146.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/430146.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/430146.htmlhttp://wenku.baidu.com/view/4573aba4ce2f0066f53322e8.html

paulwong 2016-04-19 13:27 鍙戣〃璇勮
]]>
SPRING IOhttp://www.aygfsteel.com/paulwong/archive/2015/10/30/427986.htmlpaulwongpaulwongFri, 30 Oct 2015 06:05:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/10/30/427986.htmlhttp://www.aygfsteel.com/paulwong/comments/427986.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/10/30/427986.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/427986.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/427986.html濡傛涓鏉ワ紝涓嶅悓妯″潡鎴栬呬笌澶栭儴榪涜闆嗘垚鏃訛紝渚濊禆澶勭悊灝遍渶瑕佸悇鑷搴旂増鏈彿銆?br />姣斿錛岃緝鏂皊pring涓庤緝鑰佺殑quartz錛屽畠浠泦鎴愬氨浼氶亣鍒伴棶棰橈紝緇欐惌寤哄拰鍗囩駭甯︽潵涓嶄究銆?br />
鍥犳Spring IO Platform搴旇繍鑰岀敓錛屽彧瑕侀」鐩腑寮曞叆浜嗗畠錛屽閮ㄩ泦鎴愭椂渚濊禆鍏崇郴鏃犻渶鐗堟湰鍙?br />
<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-core</artifactId> 
</dependency>

Spring IO Platform鍙槸涓涓猵om鏂囦歡錛岃褰曚簡spring涓庡叾浠栧紑婧愰」鐩搴旂殑鐗堟湰銆?br />鐪佸幓浜嗙増鏈彿錛屼篃灝辯渷鍘諱簡澶勭悊渚濊禆鏃剁殑闂錛屽洜涓篠pring IO Platform涓湁鏈浼樼殑鐗堟湰銆?img src ="http://www.aygfsteel.com/paulwong/aggbug/427986.html" width = "1" height = "1" />

paulwong 2015-10-30 14:05 鍙戣〃璇勮
]]>
Spring闈㈣瘯闂瓟Top 25http://www.aygfsteel.com/paulwong/archive/2015/04/30/424783.htmlpaulwongpaulwongThu, 30 Apr 2015 05:29:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/04/30/424783.htmlhttp://www.aygfsteel.com/paulwong/comments/424783.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/04/30/424783.html#Feedback1http://www.aygfsteel.com/paulwong/comments/commentRss/424783.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/424783.html闃呰鍏ㄦ枃

paulwong 2015-04-30 13:29 鍙戣〃璇勮
]]>
SPRING CACHE涔婥oncurrentMapCacheManager鏀歸?/title><link>http://www.aygfsteel.com/paulwong/archive/2015/02/25/423034.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Wed, 25 Feb 2015 08:34:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2015/02/25/423034.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/423034.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2015/02/25/423034.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/423034.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/423034.html</trackback:ping><description><![CDATA[ConcurrentMapCacheManager鍙互浣滀負涓縐嶇紦瀛樻柟妗堬紝浣嗕笉鑳借緗繃鏈燂紝鏈澶х紦瀛樻潯鐩瓑錛岄渶榪涜鏀歸犮?br /> <ol> <li>pom.xml涓姞鍏ヤ緷璧栧寘<br /> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->        <span style="color: #0000FF; "><</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span>com.google.guava<span style="color: #0000FF; "></</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span>guava<span style="color: #0000FF; "></</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">version</span><span style="color: #0000FF; ">></span>18.0<span style="color: #0000FF; "></</span><span style="color: #800000; ">version</span><span style="color: #0000FF; ">></span><br />        <span style="color: #0000FF; "></</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span></div> <br /> </li> <li>鏀歸燙acheManager錛孧yConcurrentMapCacheManager<br /> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">package</span> com.paul.common.cache;<br /><span style="color: #008000; ">/*</span><span style="color: #008000; "><br /> * Copyright 2002-2014 the original author or authors.<br /> *<br /> * Licensed under the Apache License, Version 2.0 (the "License");<br /> * you may not use this file except in compliance with the License.<br /> * You may obtain a copy of the License at<br /> *<br /> *      </span><span style="color: #008000; text-decoration: underline; ">http://www.apache.org/licenses/LICENSE-2.0</span><span style="color: #008000; "><br /> *<br /> * Unless required by applicable law or agreed to in writing, software<br /> * distributed under the License is distributed on an "AS IS" BASIS,<br /> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br /> * See the License for the specific language governing permissions and<br /> * limitations under the License.<br /> </span><span style="color: #008000; ">*/</span><br /><br /><span style="color: #0000FF; ">import</span> java.util.Collection;<br /><span style="color: #0000FF; ">import</span> java.util.Collections;<br /><span style="color: #0000FF; ">import</span> java.util.Map;<br /><span style="color: #0000FF; ">import</span> java.util.concurrent.ConcurrentHashMap;<br /><span style="color: #0000FF; ">import</span> java.util.concurrent.ConcurrentMap;<br /><span style="color: #0000FF; ">import</span> java.util.concurrent.TimeUnit;<br /><br /><span style="color: #0000FF; ">import</span> org.springframework.cache.Cache;<br /><span style="color: #0000FF; ">import</span> org.springframework.cache.CacheManager;<br /><span style="color: #0000FF; ">import</span> org.springframework.cache.concurrent.ConcurrentMapCache;<br /><br /><span style="color: #0000FF; ">import</span> com.google.common.cache.CacheBuilder;<br /><br /><span style="color: #008000; ">/**</span><span style="color: #008000; "><br /> * {</span><span style="color: #808080; ">@link</span><span style="color: #008000; "> CacheManager} implementation that lazily builds {</span><span style="color: #808080; ">@link</span><span style="color: #008000; "> ConcurrentMapCache}<br /> * instances for each {</span><span style="color: #808080; ">@link</span><span style="color: #008000; "> #getCache} request. Also supports a 'static' mode where<br /> * the set of cache names is pre-defined through {</span><span style="color: #808080; ">@link</span><span style="color: #008000; "> #setCacheNames}, with no<br /> * dynamic creation of further cache regions at runtime.<br /> *<br /> * <p>Note: This is by no means a sophisticated CacheManager; it comes with no<br /> * cache configuration options. However, it may be useful for testing or simple<br /> * caching scenarios. For advanced local caching needs, consider<br /> * {</span><span style="color: #808080; ">@link</span><span style="color: #008000; "> org.springframework.cache.guava.GuavaCacheManager} or<br /> * {</span><span style="color: #808080; ">@link</span><span style="color: #008000; "> org.springframework.cache.ehcache.EhCacheCacheManager}.<br /> *<br /> * </span><span style="color: #808080; ">@author</span><span style="color: #008000; "> Juergen Hoeller<br /> * </span><span style="color: #808080; ">@since</span><span style="color: #008000; "> 3.1<br /> * </span><span style="color: #808080; ">@see</span><span style="color: #008000; "> ConcurrentMapCache<br /> </span><span style="color: #008000; ">*/</span><br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> MyConcurrentMapCacheManager <span style="color: #0000FF; ">implements</span> CacheManager {<br /><br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">final</span> ConcurrentMap<String, Cache> cacheMap = <span style="color: #0000FF; ">new</span> ConcurrentHashMap<String, Cache>(16);<br /><br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">boolean</span> dynamic = <span style="color: #0000FF; ">true</span>;<br /><br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">boolean</span> allowNullValues = <span style="color: #0000FF; ">true</span>;<br />    <br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">long</span> expireTime = 30;<br />    <br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">long</span> maximumSize = 100;<br /><br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Construct a dynamic ConcurrentMapCacheManager,<br />     * lazily creating cache instances as they are being requested.<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">public</span> MyConcurrentMapCacheManager() {<br />    }<br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Construct a static ConcurrentMapCacheManager,<br />     * managing caches for the specified cache names only.<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">public</span> MyConcurrentMapCacheManager(<span style="color: #0000FF; ">long</span> expireTime, <span style="color: #0000FF; ">long</span> maximumSize) {<br />        <span style="color: #0000FF; ">if</span>(expireTime > 0)<br />            <span style="color: #0000FF; ">this</span>.expireTime = expireTime;<br />        <span style="color: #0000FF; ">if</span>(maximumSize > 0)<br />            <span style="color: #0000FF; ">this</span>.maximumSize = maximumSize;<br />    }<br /><br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Specify the set of cache names for this CacheManager's 'static' mode.<br />     * <p>The number of caches and their names will be fixed after a call to this method,<br />     * with no creation of further cache regions at runtime.<br />     * <p>Calling this with a {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> null} collection argument resets the<br />     * mode to 'dynamic', allowing for further creation of caches again.<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> setCacheNames(Collection<String> cacheNames) {<br />        <span style="color: #0000FF; ">if</span> (cacheNames != <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">for</span> (String name : cacheNames) {<br />                <span style="color: #0000FF; ">this</span>.cacheMap.put(name, createConcurrentMapCache(name));<br />            }<br />            <span style="color: #0000FF; ">this</span>.dynamic = <span style="color: #0000FF; ">false</span>;<br />        }<br />        <span style="color: #0000FF; ">else</span> {<br />            <span style="color: #0000FF; ">this</span>.dynamic = <span style="color: #0000FF; ">true</span>;<br />        }<br />    }<br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Specify whether to accept and convert {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> null} values for all caches<br />     * in this cache manager.<br />     * <p>Default is "true", despite ConcurrentHashMap itself not supporting {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> null}<br />     * values. An internal holder object will be used to store user-level {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> null}s.<br />     * <p>Note: A change of the null-value setting will reset all existing caches,<br />     * if any, to reconfigure them with the new null-value requirement.<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> setAllowNullValues(<span style="color: #0000FF; ">boolean</span> allowNullValues) {<br />        <span style="color: #0000FF; ">if</span> (allowNullValues != <span style="color: #0000FF; ">this</span>.allowNullValues) {<br />            <span style="color: #0000FF; ">this</span>.allowNullValues = allowNullValues;<br />            <span style="color: #008000; ">//</span><span style="color: #008000; "> Need to recreate all Cache instances with the new null-value configuration<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span style="color: #008000; "><br /></span>            <span style="color: #0000FF; ">for</span> (Map.Entry<String, Cache> entry : <span style="color: #0000FF; ">this</span>.cacheMap.entrySet()) {<br />                entry.setValue(createConcurrentMapCache(entry.getKey()));<br />            }<br />        }<br />    }<br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Return whether this cache manager accepts and converts {</span><span style="color: #808080; ">@code</span><span style="color: #008000; "> null} values<br />     * for all of its caches.<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">boolean</span> isAllowNullValues() {<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">this</span>.allowNullValues;<br />    }<br /><br /><br />    @Override<br />    <span style="color: #0000FF; ">public</span> Collection<String> getCacheNames() {<br />        <span style="color: #0000FF; ">return</span> Collections.unmodifiableSet(<span style="color: #0000FF; ">this</span>.cacheMap.keySet());<br />    }<br /><br />    @Override<br />    <span style="color: #0000FF; ">public</span> Cache getCache(String name) {<br />        Cache cache = <span style="color: #0000FF; ">this</span>.cacheMap.get(name);<br />        <span style="color: #0000FF; ">if</span> (cache == <span style="color: #0000FF; ">null</span> && <span style="color: #0000FF; ">this</span>.dynamic) {<br />            <span style="color: #0000FF; ">synchronized</span> (<span style="color: #0000FF; ">this</span>.cacheMap) {<br />                cache = <span style="color: #0000FF; ">this</span>.cacheMap.get(name);<br />                <span style="color: #0000FF; ">if</span> (cache == <span style="color: #0000FF; ">null</span>) {<br />                    cache = createConcurrentMapCache(name);<br />                    <span style="color: #0000FF; ">this</span>.cacheMap.put(name, cache);<br />                }<br />            }<br />        }<br />        <span style="color: #0000FF; ">return</span> cache;<br />    }<br /><br />    <span style="color: #008000; ">/**</span><span style="color: #008000; "><br />     * Create a new ConcurrentMapCache instance for the specified cache name.<br />     * </span><span style="color: #808080; ">@param</span><span style="color: #008000; "> name the name of the cache<br />     * </span><span style="color: #808080; ">@return</span><span style="color: #008000; "> the ConcurrentMapCache (or a decorator thereof)<br />     </span><span style="color: #008000; ">*/</span><br />    <span style="color: #0000FF; ">protected</span> Cache createConcurrentMapCache(String name) {<br /><span style="color: #008000; ">        //</span><span style="color: #008000; ">return new ConcurrentMapCache(name, isAllowNullValues());<br /></span><span style="color: #008000; ">        //</span><span style="color: #008000; ">姝ゅ鏀圭敤GOOGLE GUAVA鐨勬瀯閫燤ANAGER鏂瑰紡</span><span style="color: #008000; "><br /></span>        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> ConcurrentMapCache(name,<br />                                        CacheBuilder.newBuilder()<br />                                                    .expireAfterWrite(<span style="color: #0000FF; ">this</span>.expireTime, TimeUnit.MINUTES)<br />                                                    .maximumSize(<span style="color: #0000FF; ">this</span>.maximumSize)<br />                                                    .build()<br />                                                    .asMap(), <br />                                        isAllowNullValues());<br />    }<br /><br />}</div><br /> <br /> </li> <li>閰嶇疆鎯崇潃bean, cache-concurrentmap-applicationcontext.xml<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; "><?</span><span style="color: #FF00FF; ">xml version="1.0" encoding="UTF-8"</span><span style="color: #0000FF; ">?></span><br /><span style="color: #0000FF; "><</span><span style="color: #800000; ">beans </span><span style="color: #FF0000; ">xmlns</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/beans"</span><span style="color: #FF0000; "><br />    xmlns:xsi</span><span style="color: #0000FF; ">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="color: #FF0000; "> xmlns:context</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/context"</span><span style="color: #FF0000; "><br />    xmlns:cache</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/cache"</span><span style="color: #FF0000; "><br />    xmlns:p</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/p"</span><span style="color: #FF0000; "><br />    xmlns:c</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/c"</span><span style="color: #FF0000; "><br />    xmlns:jee</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/jee"</span><span style="color: #FF0000; "><br />    xmlns:util</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/util"</span><span style="color: #FF0000; "><br />    xsi:schemaLocation</span><span style="color: #0000FF; ">="http://www.springframework.org/schema/context<br />          http://www.springframework.org/schema/context/spring-context-3.0.xsd<br />          http://www.springframework.org/schema/beans<br />          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd<br />          http://www.springframework.org/schema/cache<br />          http://www.springframework.org/schema/cache/spring-cache.xsd<br />          http://www.springframework.org/schema/jee <br />          http://www.springframework.org/schema/jee/spring-jee.xsd<br />          http://www.springframework.org/schema/util<br />          http://www.springframework.org/schema/util/spring-util.xsd"</span><span style="color: #0000FF; ">></span><br /><br />    <span style="color: #0000FF; "><</span><span style="color: #800000; ">cache:annotation-driven </span><span style="color: #0000FF; ">/></span><br /><br />    <span style="color: #008000; "><!--</span><span style="color: #008000; "> <bean id="cacheManager"<br />        class="org.springframework.cache.concurrent.ConcurrentMapCacheManager" ><br />        <property name="cacheNames"><br />            <list><br />                <value>my-local-cache</value><br />            </list><br />        </property><br />    </bean> </span><span style="color: #008000; ">--></span><br />    <br />    <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="cacheManager"</span><span style="color: #FF0000; "><br />        class</span><span style="color: #0000FF; ">="com.paul.common.cache.MyConcurrentMapCacheManager"</span><span style="color: #0000FF; ">></span><br />        <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="0"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="1"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br />        <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="1"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="5000"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br />    <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span>    <br />    <br /><span style="color: #0000FF; "></</span><span style="color: #800000; ">beans</span><span style="color: #0000FF; ">></span></div> <br /> <br /> </li> <li>閫氳繃娉ㄩ噴榪涜浣跨敤<br /> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008000; ">/*</span><span style="color: #008000; "><br /> * JBoss, Home of Professional Open Source<br /> * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual<br /> * contributors by the @authors tag. See the copyright.txt in the<br /> * distribution for a full listing of individual contributors.<br /> *<br /> * Licensed under the Apache License, Version 2.0 (the "License");<br /> * you may not use this file except in compliance with the License.<br /> * You may obtain a copy of the License at<br /> * </span><span style="color: #008000; text-decoration: underline; ">http://www.apache.org/licenses/LICENSE-2.0</span><span style="color: #008000; "><br /> * Unless required by applicable law or agreed to in writing, software<br /> * distributed under the License is distributed on an "AS IS" BASIS,<br /> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br /> * See the License for the specific language governing permissions and<br /> * limitations under the License.<br /> </span><span style="color: #008000; ">*/</span><br /><span style="color: #0000FF; ">package</span> com.paul.springmvc.data;<br /><br /><span style="color: #0000FF; ">import</span> java.util.List;<br /><br /><span style="color: #0000FF; ">import</span> javax.persistence.EntityManager;<br /><span style="color: #0000FF; ">import</span> javax.persistence.criteria.CriteriaBuilder;<br /><span style="color: #0000FF; ">import</span> javax.persistence.criteria.CriteriaQuery;<br /><span style="color: #0000FF; ">import</span> javax.persistence.criteria.Root;<br /><br /><span style="color: #0000FF; ">import</span> org.springframework.beans.factory.annotation.Autowired;<br /><span style="color: #0000FF; ">import</span> org.springframework.cache.annotation.CacheEvict;<br /><span style="color: #0000FF; ">import</span> org.springframework.cache.annotation.Cacheable;<br /><span style="color: #0000FF; ">import</span> org.springframework.stereotype.Repository;<br /><span style="color: #0000FF; ">import</span> org.springframework.transaction.annotation.Transactional;<br /><br /><span style="color: #0000FF; ">import</span> com.paul.springmvc.model.Member;<br /><br />@Repository<br />@Transactional<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> MemberDaoImpl <span style="color: #0000FF; ">implements</span> MemberDao {<br />    @Autowired<br />    <span style="color: #0000FF; ">private</span> EntityManager em;<br /><br />    @Cacheable(value = "my-local-cache", key = "#id")<br />    <span style="color: #0000FF; ">public</span> Member findById(Long id) {<br />        System.out.println("<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" />MemberDaoImpl NO CACHE<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" />");<br />        <span style="color: #0000FF; ">return</span> em.find(Member.<span style="color: #0000FF; ">class</span>, id);<br />    }<br /><br />    <span style="color: #0000FF; ">public</span> Member findByEmail(String email) {<br />        CriteriaBuilder cb = em.getCriteriaBuilder();<br />        CriteriaQuery<Member> criteria = cb.createQuery(Member.<span style="color: #0000FF; ">class</span>);<br />        Root<Member> member = criteria.from(Member.<span style="color: #0000FF; ">class</span>);<br /><br />        <span style="color: #008000; ">/*</span><span style="color: #008000; "><br />         * Swap criteria statements if you would like to try out type-safe criteria queries, a new<br />         * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));<br />         </span><span style="color: #008000; ">*/</span><br /><br />        criteria.select(member).where(cb.equal(member.get("email"), email));<br />        <span style="color: #0000FF; ">return</span> em.createQuery(criteria).getSingleResult();<br />    }<br /><br />    <span style="color: #0000FF; ">public</span> List<Member> findAllOrderedByName() {<br />        CriteriaBuilder cb = em.getCriteriaBuilder();<br />        CriteriaQuery<Member> criteria = cb.createQuery(Member.<span style="color: #0000FF; ">class</span>);<br />        Root<Member> member = criteria.from(Member.<span style="color: #0000FF; ">class</span>);<br /><br />        <span style="color: #008000; ">/*</span><span style="color: #008000; "><br />         * Swap criteria statements if you would like to try out type-safe criteria queries, a new<br />         * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));<br />         </span><span style="color: #008000; ">*/</span><br /><br />        criteria.select(member).orderBy(cb.asc(member.get("name")));<br />        <span style="color: #0000FF; ">return</span> em.createQuery(criteria).getResultList();<br />    }<br /><br />    @CacheEvict(value="my-local-cache",allEntries=<span style="color: #0000FF; ">true</span>,beforeInvocation=<span style="color: #0000FF; ">true</span>)<span style="color: #008000; ">//</span><span style="color: #008000; ">娓呯┖鎵鏈夌紦瀛?/span><span style="color: #008000; "><br /></span>    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> register(Member member) {<br />        em.persist(member);<br />        <span style="color: #0000FF; ">return</span>;<br />    }<br />}</div></li> </ol><img src ="http://www.aygfsteel.com/paulwong/aggbug/423034.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2015-02-25 16:34 <a href="http://www.aygfsteel.com/paulwong/archive/2015/02/25/423034.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>SPRING CACHE璧勬簮http://www.aygfsteel.com/paulwong/archive/2015/02/25/423032.htmlpaulwongpaulwongWed, 25 Feb 2015 08:04:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/02/25/423032.htmlhttp://www.aygfsteel.com/paulwong/comments/423032.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/02/25/423032.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/423032.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/423032.html
http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/htmlsingle/#cache

SPRING CONCURRENTMAP MANAGER鍔犺繃鏈熺瓥鐣?br />http://stackoverflow.com/questions/8181768/can-i-set-a-ttl-for-cacheable

緇勫悎KEY
http://stackoverflow.com/questions/14072380/cacheable-key-on-multiple-method-arguments

Spring Cache鎶借薄璇﹁В
http://www.open-open.com/lib/view/open1389575623336.html

娉ㄩ噴椹卞姩鐨?Spring cache 緙撳瓨浠嬬粛
https://www.ibm.com/developerworks/cn/opensource/os-cn-spring-cache/

Spring Cache鎶借薄璇﹁В



paulwong 2015-02-25 16:04 鍙戣〃璇勮
]]>
Architecture for Redis cache & Mongo for persistencehttp://www.aygfsteel.com/paulwong/archive/2015/01/04/422026.htmlpaulwongpaulwongSun, 04 Jan 2015 07:50:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/01/04/422026.htmlhttp://www.aygfsteel.com/paulwong/comments/422026.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/01/04/422026.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/422026.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/422026.htmlhttp://www.javacodegeeks.com/2013/02/caching-with-spring-data-redis.html

Architecture for Redis cache & Mongo for persistence
http://stackoverflow.com/questions/11218941/architecture-for-redis-cache-mongo-for-persistence

MongoDB with redis
http://stackoverflow.com/questions/10696463/mongodb-with-redis/10721249#10721249

Caching Data in Spring Using Redis
http://caseyscarborough.com/blog/2014/12/18/caching-data-in-spring-using-redis/

Springside Redis
https://github.com/springside/springside4/wiki/Redis

Spring Cache娉ㄨВ+Redis
http://hanqunfeng.iteye.com/blog/2176172















paulwong 2015-01-04 15:50 鍙戣〃璇勮
]]>
SPRING-SESSIONhttp://www.aygfsteel.com/paulwong/archive/2014/11/19/420309.htmlpaulwongpaulwongWed, 19 Nov 2014 10:23:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/11/19/420309.htmlhttp://www.aygfsteel.com/paulwong/comments/420309.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/11/19/420309.html#Feedback1http://www.aygfsteel.com/paulwong/comments/commentRss/420309.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/420309.html闃呰鍏ㄦ枃

paulwong 2014-11-19 18:23 鍙戣〃璇勮
]]>
Spring Boothttp://www.aygfsteel.com/paulwong/archive/2014/10/11/418634.htmlpaulwongpaulwongSat, 11 Oct 2014 12:34:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/10/11/418634.htmlhttp://www.aygfsteel.com/paulwong/comments/418634.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/10/11/418634.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/418634.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/418634.html Spring Boot 鍦?Spring 鐢熸佷腑鐨勪綅緗細

Spring Boot in Context

https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples



paulwong 2014-10-11 20:34 鍙戣〃璇勮
]]>
Spring瀵笻ttpSession鐨勯噸鏂板皝闂?/title><link>http://www.aygfsteel.com/paulwong/archive/2014/08/19/417090.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 19 Aug 2014 01:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2014/08/19/417090.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/417090.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2014/08/19/417090.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/417090.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/417090.html</trackback:ping><description><![CDATA[<a target="_blank">https://github.com/spring-projects/spring-session/tree/master/samples</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/417090.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2014-08-19 09:13 <a href="http://www.aygfsteel.com/paulwong/archive/2014/08/19/417090.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鑷畾涔夋敞閲婁笌鎿嶄綔琛屼負璁板綍http://www.aygfsteel.com/paulwong/archive/2014/07/25/416201.htmlpaulwongpaulwongFri, 25 Jul 2014 06:56:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/07/25/416201.htmlhttp://www.aygfsteel.com/paulwong/comments/416201.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/07/25/416201.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/416201.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/416201.html鑷畾涔夋敞閲婂氨鏄竴涓爣璁幫紝涓涓俊鎭敹闆嗗櫒錛屽鏋滈厤鍚圫PRING鐨凙OP浣跨敤錛屽彲浠ヨ褰曠敤鎴風殑鎿嶄綔琛屼負銆?br />
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 鏂板鐨勭敤娉?@Audit(behaviour="鏂板浜嗕笓棰?, 
 *            value="#{args[0].colSubject}")
 *
 * 淇敼鐨勭敤娉?@Audit(behaviour="淇敼浜嗕笓棰?, id="#{args[0].colSubject.id}", 
 *            className="com.paul.program.colsubject.valueobject.ColSubject",
 *            value="#{args[0].colSubject}")
 *
 * 鍒犻櫎鐨勭敤娉?@Audit(behaviour="鍒犻櫎浜嗕笓棰?, id="#{args[0].colSubject.id}"
 *             className="com.paul.program.colsubject.valueobject.ColSubject")
 *             
 * 
@author PAUL
 *
 
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Audit {
    
    String id() default "";
    String className() default "";
    String collectionName() default "";
    String value() default "";
    String behaviour();

}


鍊煎璞?br /> AuditData.java
package com.paul.common.audit;

import java.io.Serializable;
import java.util.Date;

import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import com.paul.common.util.jackson.CustomJsonDateSerializer;

@Document(collection = "auditdata")
public class AuditData implements Serializable{

    private static final long serialVersionUID = -4011585863836336249L;
    
    @Id
    private String id;
    
    @CreatedBy
    @Field("userid")
    @JsonProperty("userid")
    private String userId;
    
    @CreatedDate
    @Field("createdate")
    @JsonProperty("createdate")
    @JsonSerialize(using = CustomJsonDateSerializer.class)
    private Date createDate;
    
    private String behaviour;
    
    @Field("newvalue")
    @JsonProperty("newvalue")
    private String newValue;
    
    @Field("oldvalue")
    @JsonProperty("oldvalue")
    private String oldValue;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getBehaviour() {
        return behaviour;
    }

    public void setBehaviour(String behaviour) {
        this.behaviour = behaviour;
    }


    public String getNewValue() {
        return newValue;
    }

    public void setNewValue(String newValue) {
        this.newValue = newValue;
    }

    public String getOldValue() {
        return oldValue;
    }

    public void setOldValue(String oldValue) {
        this.oldValue = oldValue;
    }

    public String toString() {
        return "AuditData [id=" + id + ", userId=" + userId + ", createDate="
                + createDate + ", behaviour=" + behaviour + ", newValue="
                + newValue + ", oldValue=" + oldValue + "]";
    }
    

}


RootObject.java
package com.paul.common.audit;

public class RootObject {

    private final Object[] args;

    private final Object invokedObject;

    private final Object returned;

    private final Throwable throwned;

    public RootObject(Object invokedObject, Object[] args, Object returned, Throwable throwned) {
        super();
        this.invokedObject = invokedObject;
        this.args = args;
        this.returned = returned;
        this.throwned = throwned;
    }

    public Object[] getArgs() {
        return args;
    }

    public Object getInvokedObject() {
        return invokedObject;
    }

    public Object getReturned() {
        return returned;
    }

    public Throwable getThrowned() {
        return throwned;
    }

}


TemplateParserContext.java
package com.paul.common.audit;

import org.springframework.expression.ParserContext;

public class TemplateParserContext implements ParserContext {

    public String getExpressionPrefix() {
        return "#{";
    }

    public String getExpressionSuffix() {
        return "}";
    }

    public boolean isTemplate() {
        return true;
    }
}


鑾峰彇鐢ㄦ埛ID
package com.paul.common.audit.aware;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.paul.common.constant.Constants;
import com.paul.program.account.valueobject.Account;

@Component
public class MyAppAuditor implements AuditorAware<String> {
    
    private static Logger logger = LoggerFactory.getLogger(MyAppAuditor.class);

    // get your user name here
    public String getCurrentAuditor() {
        
        String result = "N/A";
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
                    .getRequestAttributes()).getRequest();
            Account account = (Account)request.getSession().getAttribute(Constants.USER_INFO);
            result = account.getLoginName();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return result;
    }
}


鍒囬潰
package com.paul.common.audit.interceptor;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.ParserContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.stereotype.Component;

import com.paul.common.audit.AuditData;
import com.paul.common.audit.AuditDataRequest;
import com.paul.common.audit.RootObject;
import com.paul.common.audit.TemplateParserContext;
import com.paul.common.audit.annotation.Audit;
import com.paul.common.audit.service.AuditDataService;
import com.paul.common.util.StringUtils;

@Component
@Aspect
public class AuditAspect {
    
    private static Logger logger = LoggerFactory.getLogger(AuditAspect.class);
    
    @Autowired
    private AuditDataService auditDataService;
    
    @Autowired
    private MongoTemplate mongoTemplate;
    
    private SimpleDateFormat dateFormatPrototype = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private Map<String, Expression> expressionCache = new ConcurrentHashMap<String, Expression>();

    private ExpressionParser expressionParser = new SpelExpressionParser();

    private ParserContext parserContext = new TemplateParserContext();
    

    protected static void appendThrowableCauses(Throwable throwable, String separator, StringBuilder toAppendTo) {
        List<Throwable> alreadyAppendedThrowables = new ArrayList<Throwable>();

        while (throwable != null) {
            // append
            toAppendTo.append(throwable.toString());
            alreadyAppendedThrowables.add(throwable);

            // cause
            Throwable cause = throwable.getCause();
            if (cause == null || alreadyAppendedThrowables.contains(cause)) {
                break;
            } else {
                throwable = cause;
                toAppendTo.append(separator);
            }
        }
    }
    
    private String getValueByEl(String template, Object invokedObject, Object[] args, Object returned, Throwable throwned)
    {
        String result = "N/A";
        if(StringUtils.isBlank(template))
            return result;
        try {
            Expression expression = expressionCache.get(template);
            if (expression == null) {
                expression = expressionParser.parseExpression(template, parserContext);
                expressionCache.put(template, expression);
            }

            Object evaluatedMessage = expression.getValue(new RootObject(invokedObject, args, returned, throwned), Object.class);
            result = evaluatedMessage.toString();
        } catch (ParseException e) {
            logger.error(e.getMessage(), e);
        } catch (EvaluationException e) {
            logger.error(e.getMessage(), e);
        }
        return result;
    }


    protected AuditData buildAuditData(Audit auditAnnotation, Object invokedObject, Object[] args, Object returned, Throwable throwned, long durationInNanos) {
        
        AuditData auditData = new AuditData();
        auditData.setBehaviour(auditAnnotation.behaviour());
        String id = this.getValueByEl(auditAnnotation.id(), invokedObject, args, returned, throwned);
        auditData.setOldValue(this.getOldValueToString(id, auditAnnotation.className()));
        try {
            String newValue = this.getValueByEl(auditAnnotation.value(), invokedObject, args, returned, throwned);
            auditData.setNewValue(newValue);

            StringBuilder msg = new StringBuilder();

            SimpleDateFormat simpleDateFormat = (SimpleDateFormat) dateFormatPrototype.clone();
            msg.append(simpleDateFormat.format(new Date()));
//            auditData.setCreateDate(simpleDateFormat.format(new Date()));

            msg.append(" ").append(newValue);

            if (throwned != null) {
                msg.append(" threw '");
                appendThrowableCauses(throwned, ", ", msg);
                msg.append("'");
            }
            msg.append(" by ");
            String user = this.getUser();
            if (user == null) {
                user = "anonymous";
            } 
            msg.append(" in ") .append(TimeUnit.MILLISECONDS.convert(durationInNanos, TimeUnit.NANOSECONDS)).append(" ms");
            return auditData;
        } catch (Exception e) {
            /*StringBuilder msg = new StringBuilder("Exception evaluating template '" + template + "': ");
            appendThrowableCauses(e, ", ", msg);
*/
            return auditData;
        }
    }
    
    private String getOldValueToString(/*ProceedingJoinPoint proceedingJoinPoint,*/ String id, String className) 
    {
        String result = "N/A";
        /*String id = "5385be613d2a47eec07c53d4";
        try {
            MethodSignature methodSig = (MethodSignature) proceedingJoinPoint.getSignature();
            Object target = proceedingJoinPoint.getTarget();
            Object newValue = proceedingJoinPoint.getArgs()[0];
            String findMethodName = "findOne";
            Object oldValue=null;
            Method findMethod = target.getClass().getDeclaredMethod(findMethodName, (Class<?>[])null);
            oldValue = findMethod.invoke(target, (Object[]) null);

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
*/
        if(StringUtils.isBlank(id) || StringUtils.isBlank(className))
            return result;
        
        try {
            Object object = mongoTemplate.findById(id, Class.forName(className));
            result = ToStringBuilder.reflectionToString(object,  ToStringStyle.SHORT_PREFIX_STYLE); 
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return result;
    }
    
//    @Around("execution(* com.paul..**.repository..*(..))")
    @Around("@annotation(auditAnnotation)")
    public Object aroundAdvice(ProceedingJoinPoint proceedingJoinPoint, Audit auditAnnotation) throws Throwable {
        
        boolean ok = false;
        Object o = null;
        AuditData auditData = null;
        try 
        {
            auditData = buildAuditData(auditAnnotation, proceedingJoinPoint.getThis(), 
                    proceedingJoinPoint.getArgs(), 
                    o, null, 10);
            o = proceedingJoinPoint.proceed();
            ok = true;
            return o;
        } 
        finally 
        {
            if (ok)
            {
//                String value = (MessageFormat.format(auditAnnotation.value(), proceedingJoinPoint.getArgs()));
                try 
                {
                    AuditDataRequest auditDataRequest = new AuditDataRequest();
                    auditDataRequest.setAuditData(auditData);
                    auditDataService.addAuditData(auditDataRequest);
                    logger.info(auditData + "");
                } 
                catch (Exception e) 
                {
                    logger.error(e.getMessage(), e);
                }
            }    
        }
    }
    
    private String getUser()
    {
        return "Paul";
    }
    

}


淇濆瓨鑷蟲暟鎹簱
package com.paul.common.audit.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import com.paul.common.audit.AuditData;
import com.paul.common.audit.AuditDataRequest;
import com.paul.common.audit.annotation.Audit;
import com.paul.common.audit.repository.AuditDataRepository;
import com.paul.program.colsubject.valueobject.ColSubjectRequest;

@Service
public class AuditDataService {
    
    @Autowired
    private AuditDataRepository auditDataRepository;
    
//    @Audited(message = "save(#{args[0].name}, #{args[0].email}): #{returned?.id}")
    @Audit(behaviour="淇敼浜嗗璁?, id="#{args[0].colSubject.id}", 
            className="com.paul.program.colsubject.valueobject.ColSubject",
            value="#{args[0].colSubject}")
    public void saveObject(ColSubjectRequest colSubjectRequest)
    {
        
    }
    
    @Audit(behaviour="鍒犻櫎浜嗕笓棰?, id="#{args[0]}",
             className="com.paul.program.subject.valueobject.Subject")
    public void delete(String id) {
    }
    
    @Audit(behaviour="鏂板浜嗕笓棰?, value="#{args[0].colSubject}")
    public void add(ColSubjectRequest colSubjectRequest) {
    }
    
    public AuditData addAuditData(AuditDataRequest auditDataRequest)
    {
        return auditDataRepository.save(auditDataRequest.getAuditData());
    }
    
    public Page<AuditData> findAll(AuditDataRequest auditDataRequest)
    {
        Page<AuditData> page = auditDataRepository.findAll(auditDataRequest.getPageable());
        return page;
    }

}


DAO
package com.paul.common.audit.repository;

import org.springframework.data.repository.PagingAndSortingRepository;

import com.paul.common.audit.AuditData;

/**
 * 瀹¤
 * 
 
*/
public interface AuditDataRepository extends PagingAndSortingRepository<AuditData, String>{
    
}


paulwong 2014-07-25 14:56 鍙戣〃璇勮
]]>
Audit in Spring AOPhttp://www.aygfsteel.com/paulwong/archive/2014/07/18/415969.htmlpaulwongpaulwongFri, 18 Jul 2014 01:50:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/07/18/415969.htmlhttp://www.aygfsteel.com/paulwong/comments/415969.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/07/18/415969.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/415969.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/415969.htmlhttp://maciejwalkowiak.pl/blog/2013/05/24/auditing-entities-in-spring-data-mongodb/


xebia-spring-security-extras
https://github.com/xebia-france/xebia-spring-security-extras/wiki/AuditedAnnotation


Spring Logging using custom annotation
http://stackoverflow.com/questions/15298164/spring-logging-using-custom-annotation


Spring MVC and MongoDB - Auditing Actions
http://www.alexecollins.com/content/spring-mvc-and-mongodb-auditing-actions/


audit-aspectj 
https://github.com/roghughe/captaindebug/tree/master/audit-aspectj

paulwong 2014-07-18 09:50 鍙戣〃璇勮
]]>
Spring Data REST錛孲pring MVC鐨凴EST鎵╁睍http://www.aygfsteel.com/paulwong/archive/2014/07/09/415635.htmlpaulwongpaulwongWed, 09 Jul 2014 09:36:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/07/09/415635.htmlhttp://www.aygfsteel.com/paulwong/comments/415635.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/07/09/415635.html#Feedback1http://www.aygfsteel.com/paulwong/comments/commentRss/415635.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/415635.htmlhttp://spring.io/blog/2012/06/26/spring-data-rest-1-0-0-rc1-released

RESTify your JPA Entities
https://www.openshift.com/blogs/restify-your-jpa-entities

babdev-spring
https://github.com/gregorriegler/babdev-spring/tree/master/spring-data-rest

https://github.com/spring-projects/spring-data-rest

paulwong 2014-07-09 17:36 鍙戣〃璇勮
]]>
Spring Data Dijkstrahttp://www.aygfsteel.com/paulwong/archive/2014/07/01/415332.htmlpaulwongpaulwongTue, 01 Jul 2014 02:49:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/07/01/415332.htmlhttp://www.aygfsteel.com/paulwong/comments/415332.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/07/01/415332.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/415332.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/415332.html涓澶ф嘗Spring Data鐩稿叧鍖咃細
Spring Data Dijkstra SR1 鍙戝竷錛岃鐗堟湰鍖呭惈濡備笅妯″潡鐨?59 涓棶棰樹慨澶嶏細

寤鴻鎵鏈?Dijkstra 鐢ㄦ埛鍗囩駭錛屽洜涓哄寘鍚噸瑕佺殑 bug 淇銆?/p>

paulwong 2014-07-01 10:49 鍙戣〃璇勮
]]>
鍦‥JB3鐨凷ESSION BEAN涓嬌鐢⊿PRING BEANhttp://www.aygfsteel.com/paulwong/archive/2014/02/12/409777.htmlpaulwongpaulwongWed, 12 Feb 2014 08:43:00 GMThttp://www.aygfsteel.com/paulwong/archive/2014/02/12/409777.htmlhttp://www.aygfsteel.com/paulwong/comments/409777.htmlhttp://www.aygfsteel.com/paulwong/archive/2014/02/12/409777.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/409777.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/409777.htmlhttp://java.dzone.com/articles/ejb3-fa%C3%A7ade-over-spring


Using Spring’s EJB implementation support classes
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/ejb.html#ejb-implementation-ejb3



import javax.ejb.Stateless;
import javax.interceptor.Interceptors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;

import ch.frankel.blog.ejb.spring.service.client.RandomGeneratorService;

@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class RandomGeneratorBean implements RandomGeneratorService {

    @Autowired
    private ch.frankel.blog.ejb.spring.service.RandomGeneratorService delegate;

    @Override
    public int generateNumber(int lowerLimit, int upperLimit) {

        return delegate.generateNumber(lowerLimit, upperLimit);
    }
}


paulwong 2014-02-12 16:43 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 邯郸县| 宕昌县| 建瓯市| 胶南市| 余干县| 奉贤区| 宜城市| 麟游县| 丘北县| 西丰县| 鸡泽县| 永定县| 冀州市| 格尔木市| 米易县| 诏安县| 克拉玛依市| 翼城县| 博客| 铜梁县| 中山市| 湖南省| 库伦旗| 新乡县| 梁河县| 赣州市| 扶绥县| 龙井市| 绥中县| 古蔺县| 全州县| 郁南县| 新晃| 汤原县| 察哈| 迁安市| 平顶山市| 湘阴县| 福安市| 汉寿县| 富裕县|