Skip to content

Commit

Permalink
write a line into test.file
Browse files Browse the repository at this point in the history
  • Loading branch information
huifer committed Aug 23, 2023
1 parent 10ee2c3 commit de81d80
Show file tree
Hide file tree
Showing 7 changed files with 382 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/spring/cs6beef402-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2009-2016 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.submitted.lazy_properties;

import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface Mapper {
User getUser(Integer id);

@ResultMap("user")
@Select("select 11 id, 'lazy1' name from (values(0))")
User getLazy1();

@ResultMap("user")
@Select("select 12 id, 'lazy2' name from (values(0))")
User getLazy2();

@ResultMap("user")
@Select("select 13 id, 'lazy3' name from (values(0))")
List<User> getLazy3();
}
32 changes: 32 additions & 0 deletions docs/spring/cs6c39b41a-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.huifer.data.list.circularLinkedList;

/**
* <p>Title : CircularNode </p>
* <p>Description : 循环链表结点</p>
*
* @author huifer
* @date 2019-04-18
*/
public class CircularNode {

public Integer data;
public CircularNode next;

public CircularNode(Integer data) {
this.data = data;
}

public CircularNode() {
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"data\":")
.append(data);
sb.append(",\"next\":")
.append(next);
sb.append('}');
return sb.toString();
}
}
21 changes: 21 additions & 0 deletions docs/spring/cs6c8068ce-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2009-2016 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* <p>
* Base package for cursor feature
*/
/**
* Base package for cursor feature
*/
package org.apache.ibatis.cursor;
111 changes: 111 additions & 0 deletions docs/spring/cs6cc29a00-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package org.huifer.ztj.spring;

import java.util.EnumSet;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.config.StateMachineBuilder.Builder;
import org.springframework.statemachine.guard.Guard;
import org.springframework.statemachine.state.State;

public class Main {

public static void main(String[] args) throws Exception {
StateMachine<States, Events> stateMachine = buildWithInternal();
stateMachine.start();

// stateMachine.sendEvent(Events.EVENT1);

Message<Events> user_id = MessageBuilder.withPayload(Events.EVENT1).setHeader("user_id", 100)
.build();
stateMachine.sendEvent(user_id);
// stateMachine.sendEvent(Events.EVENT2);

printState(stateMachine);
System.out.println();
}

private static void printState(StateMachine<States, Events> stateMachine) {
State<States, Events> state = stateMachine.getState();
States id = state.getId();
System.out.println("发送事件之后的状态");
System.out.println(id);
}


public static StateMachine<States, Events> buildWithInternal() throws Exception {
Builder<States, Events> builder = StateMachineBuilder.builder();

builder.configureStates()
.withStates()
.initial(States.STATE1)
.end(States.STATE3)
.states(EnumSet.allOf(States.class))
;
builder.configureTransitions()
.withExternal()
.source(States.STATE1).target(States.STATE2).event(Events.EVENT1)
.guard(new Guard<States, Events>() {
@Override
public boolean evaluate(
StateContext<States, Events> context) {
return false;
}
})
.and()
// 做了什么失败了并且吧状态还原
.withInternal()
.source(States.STATE1).event(Events.EVENT1)

;

return builder.build();
}


public static StateMachine<States, Events> buildMachine() throws Exception {
Builder<States, Events> builder = StateMachineBuilder.builder();

builder.configureStates()
.withStates()
.initial(States.STATE1)
.states(EnumSet.allOf(States.class))
;
builder.configureTransitions()
.withExternal()
.source(States.STATE1).target(States.STATE2)
.event(Events.EVENT1)
.guard(new Guard<States, Events>() {
@Override
public boolean evaluate(
StateContext<States, Events> context) {
return false;
}
})

.action(new Action<States, Events>() {
@Override
public void execute(
StateContext<States, Events> context) {
// todo: 做状态变更的事情
Object user_id = context.getMessageHeaders().get("user_id");
System.out.println(user_id);
System.out.println();
}
})
;

return builder.build();
}

enum States {
STATE1, STATE2, STATE3
}

enum Events {
EVENT1, EVENT2
}
}
98 changes: 98 additions & 0 deletions docs/spring/cs6d0ebbce-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package dolores.oauthserver.service;

import dolores.oauthserver.config.OAuth2ClientProperties;
import dolores.oauthserver.config.OAuth2Properties;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.builders.InMemoryClientDetailsServiceBuilder;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

import java.util.ArrayList;
import java.util.List;

@Configuration
@EnableAuthorizationServer
public class GameAuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {

@Autowired
private OAuth2Properties oAuth2Properties;

@Autowired
private UserDetailsService userDetailsService;

@Autowired
private AuthenticationManager authenticationManager;

@Autowired
private TokenStore tokenStore;

@Autowired(required = false)
@Qualifier("jwtAccessTokenConverter")
private JwtAccessTokenConverter jwtAccessTokenConverter;

@Autowired(required = false)
@Qualifier("jwtTokenEnhancer")
private TokenEnhancer jwtTokenEnhancer;

@Autowired
private PasswordEncoder passwordEncoder;

public GameAuthorizationServerConfig() {
super();
}

@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security.tokenKeyAccess("permitAll()");
security.checkTokenAccess("isAuthenticated()");
}

@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
InMemoryClientDetailsServiceBuilder builder = clients.inMemory();

if (ArrayUtils.isNotEmpty(oAuth2Properties.getClients())) {
for (OAuth2ClientProperties config : oAuth2Properties.getClients()) {
builder.withClient(config.getClientId())
.secret(passwordEncoder.encode(config.getClientSecret()))
.accessTokenValiditySeconds(config.getAccessTokenValiditySeconds())
.refreshTokenValiditySeconds(60 * 60 * 24 * 15)
.authorizedGrantTypes("refresh_token", "password", "authorization_code")//OAuth2支持的验证模式
.redirectUris("http://www.ixx.com")
.scopes("all");
}
}
}

@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.tokenStore(tokenStore)
.authenticationManager(authenticationManager)
.userDetailsService(userDetailsService);

if (jwtAccessTokenConverter != null && jwtTokenEnhancer != null) {
TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain();
List<TokenEnhancer> enhancers = new ArrayList<>();
enhancers.add(jwtTokenEnhancer);
enhancers.add(jwtAccessTokenConverter);
tokenEnhancerChain.setTokenEnhancers(enhancers);
endpoints
.tokenEnhancer(tokenEnhancerChain)
.accessTokenConverter(jwtAccessTokenConverter);
}
}
}
59 changes: 59 additions & 0 deletions docs/spring/cs6d5cdba6-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.cache;

import org.apache.ibatis.cache.decorators.TransactionalCache;

import java.util.HashMap;
import java.util.Map;

/**
* 缓存和事物管理器
* @author Clinton Begin
*/
public class TransactionalCacheManager {

private final Map<Cache, TransactionalCache> transactionalCaches = new HashMap<>();

public void clear(Cache cache) {
getTransactionalCache(cache).clear();
}

public Object getObject(Cache cache, CacheKey key) {
return getTransactionalCache(cache).getObject(key);
}

public void putObject(Cache cache, CacheKey key, Object value) {
getTransactionalCache(cache).putObject(key, value);
}

public void commit() {
for (TransactionalCache txCache : transactionalCaches.values()) {
txCache.commit();
}
}

public void rollback() {
for (TransactionalCache txCache : transactionalCaches.values()) {
txCache.rollback();
}
}

private TransactionalCache getTransactionalCache(Cache cache) {
return transactionalCaches.computeIfAbsent(cache, TransactionalCache::new);
}

}
24 changes: 24 additions & 0 deletions docs/spring/cs6da043dc-4155-11ee-995c-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.huifer.jdk.jdk8.stearm;

import java.util.stream.Stream;

/**
* 描述:
*
* @author huifer
* @date 2019-06-16
*/
public class Demo04 {
public static void main(String[] args) {
// Stream<String> stringStream = Stream.generate(UUID.randomUUID()::toString);
Stream<String> stringStream = null;

stringStream.findFirst().get();

if (stringStream.findFirst().isPresent()) {
// TODO:.....
}
stringStream.findFirst().ifPresent(System.out::println);

}
}

0 comments on commit de81d80

Please sign in to comment.