-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
615 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright 2009-2015 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.nested_query_cache; | ||
|
||
import org.apache.ibatis.domain.blog.Author; | ||
|
||
public interface AuthorMapper { | ||
|
||
Author selectAuthor(int id); | ||
|
||
} |
213 changes: 213 additions & 0 deletions
213
docs/spring/cs411cfdc6-eb11-11ee-890e-acde48001122.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
/** | ||
* 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.io; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
|
||
/** | ||
* A class to wrap access to multiple class loaders making them work as one | ||
* | ||
* @author Clinton Begin | ||
*/ | ||
public class ClassLoaderWrapper { | ||
|
||
ClassLoader defaultClassLoader; | ||
ClassLoader systemClassLoader; | ||
|
||
ClassLoaderWrapper() { | ||
try { | ||
systemClassLoader = ClassLoader.getSystemClassLoader(); | ||
} catch (SecurityException ignored) { | ||
// AccessControlException on Google App Engine | ||
} | ||
} | ||
|
||
/** | ||
* Get a resource as a URL using the current class path | ||
* | ||
* @param resource - the resource to locate | ||
* @return the resource or null | ||
*/ | ||
public URL getResourceAsURL(String resource) { | ||
return getResourceAsURL(resource, getClassLoaders(null)); | ||
} | ||
|
||
/** | ||
* Get a resource from the classpath, starting with a specific class loader | ||
* | ||
* @param resource - the resource to find | ||
* @param classLoader - the first classloader to try | ||
* @return the stream or null | ||
*/ | ||
public URL getResourceAsURL(String resource, ClassLoader classLoader) { | ||
return getResourceAsURL(resource, getClassLoaders(classLoader)); | ||
} | ||
|
||
/** | ||
* Get a resource from the classpath | ||
* | ||
* @param resource - the resource to find | ||
* @return the stream or null | ||
*/ | ||
public InputStream getResourceAsStream(String resource) { | ||
return getResourceAsStream(resource, getClassLoaders(null)); | ||
} | ||
|
||
/** | ||
* Get a resource from the classpath, starting with a specific class loader | ||
* | ||
* @param resource - the resource to find | ||
* @param classLoader - the first class loader to try | ||
* @return the stream or null | ||
*/ | ||
public InputStream getResourceAsStream(String resource, ClassLoader classLoader) { | ||
return getResourceAsStream(resource, getClassLoaders(classLoader)); | ||
} | ||
|
||
/** | ||
* Find a class on the classpath (or die trying) | ||
* | ||
* @param name - the class to look for | ||
* @return - the class | ||
* @throws ClassNotFoundException Duh. | ||
*/ | ||
public Class<?> classForName(String name) throws ClassNotFoundException { | ||
return classForName(name, getClassLoaders(null)); | ||
} | ||
|
||
/** | ||
* Find a class on the classpath, starting with a specific classloader (or die trying) | ||
* | ||
* @param name - the class to look for | ||
* @param classLoader - the first classloader to try | ||
* @return - the class | ||
* @throws ClassNotFoundException Duh. | ||
*/ | ||
public Class<?> classForName(String name, ClassLoader classLoader) throws ClassNotFoundException { | ||
return classForName(name, getClassLoaders(classLoader)); | ||
} | ||
|
||
/** | ||
* Try to get a resource from a group of classloaders | ||
* | ||
* @param resource - the resource to get | ||
* @param classLoader - the classloaders to examine | ||
* @return the resource or null | ||
*/ | ||
InputStream getResourceAsStream(String resource, ClassLoader[] classLoader) { | ||
for (ClassLoader cl : classLoader) { | ||
if (null != cl) { | ||
|
||
// try to find the resource as passed | ||
InputStream returnValue = cl.getResourceAsStream(resource); | ||
|
||
// now, some class loaders want this leading "/", so we'll add it and try again if we didn't find the resource | ||
if (null == returnValue) { | ||
returnValue = cl.getResourceAsStream("/" + resource); | ||
} | ||
|
||
if (null != returnValue) { | ||
return returnValue; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Get a resource as a URL using the current class path | ||
* | ||
* @param resource - the resource to locate | ||
* @param classLoader - the class loaders to examine | ||
* @return the resource or null | ||
*/ | ||
URL getResourceAsURL(String resource, ClassLoader[] classLoader) { | ||
|
||
URL url; | ||
|
||
for (ClassLoader cl : classLoader) { | ||
|
||
if (null != cl) { | ||
|
||
// look for the resource as passed in... | ||
url = cl.getResource(resource); | ||
|
||
// ...but some class loaders want this leading "/", so we'll add it | ||
// and try again if we didn't find the resource | ||
if (null == url) { | ||
url = cl.getResource("/" + resource); | ||
} | ||
|
||
// "It's always in the last place I look for it!" | ||
// ... because only an idiot would keep looking for it after finding it, so stop looking already. | ||
if (null != url) { | ||
return url; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
// didn't find it anywhere. | ||
return null; | ||
|
||
} | ||
|
||
/** | ||
* Attempt to load a class from a group of classloaders | ||
* | ||
* @param name - the class to load | ||
* @param classLoader - the group of classloaders to examine | ||
* @return the class | ||
* @throws ClassNotFoundException - Remember the wisdom of Judge Smails: Well, the world needs ditch diggers, too. | ||
*/ | ||
Class<?> classForName(String name, ClassLoader[] classLoader) throws ClassNotFoundException { | ||
|
||
for (ClassLoader cl : classLoader) { | ||
|
||
if (null != cl) { | ||
|
||
try { | ||
|
||
Class<?> c = Class.forName(name, true, cl); | ||
|
||
if (null != c) { | ||
return c; | ||
} | ||
|
||
} catch (ClassNotFoundException e) { | ||
// we'll ignore this until all classloaders fail to locate the class | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
throw new ClassNotFoundException("Cannot find class: " + name); | ||
|
||
} | ||
|
||
ClassLoader[] getClassLoaders(ClassLoader classLoader) { | ||
return new ClassLoader[]{ | ||
classLoader, | ||
defaultClassLoader, | ||
Thread.currentThread().getContextClassLoader(), | ||
getClass().getClassLoader(), | ||
systemClassLoader}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright 2009-2015 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 loading results into beans | ||
*/ | ||
/** | ||
* Base package for loading results into beans | ||
*/ | ||
package org.apache.ibatis.executor.loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.huifer.simple.shiro.boot.repo; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import com.github.huifer.simple.shiro.boot.ShiroApp; | ||
import com.github.huifer.simple.shiro.boot.entity.ShiroUserEntity; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
/** | ||
* @author huifer | ||
*/ | ||
@SpringBootTest(classes = {ShiroApp.class}) | ||
public class ShiroUserRepoTest { | ||
|
||
@Autowired | ||
private ShiroUserRepo userRepo; | ||
|
||
@Test | ||
public void testFindShiroUserEntityByUsername(){ | ||
Optional<ShiroUserEntity> admin = userRepo.findShiroUserEntityByUsername("admin"); | ||
if (admin.isPresent()) { | ||
System.out.println(admin.get()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.huifer.rbac.entity.req.resource.btn; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode | ||
public class BtnQueryReq { | ||
private String name; | ||
|
||
private String type; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.huifer.springboot.alibaba.sentinel; | ||
|
||
import com.alibaba.csp.sentinel.Entry; | ||
import com.alibaba.csp.sentinel.SphU; | ||
import com.alibaba.csp.sentinel.slots.block.RuleConstant; | ||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; | ||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* @author: wang | ||
* @description: | ||
*/ | ||
public class FirstDemo { | ||
|
||
public static final String PUBLIC_RESOURCE = "PUBLIC_RESOURCE"; | ||
|
||
|
||
public static void initFlowRules(String resource) { | ||
List<FlowRule> rules = new ArrayList<>(); | ||
FlowRule rule = new FlowRule(); | ||
rule.setResource(resource); | ||
//限流阈值类型,此处为qps类型 | ||
rule.setGrade(RuleConstant.FLOW_GRADE_QPS); | ||
//限流阈值,表示每秒钟通过5次请求 | ||
rule.setCount(5); | ||
rules.add(rule); | ||
FlowRuleManager.loadRules(rules); | ||
} | ||
|
||
public static void main(String[] args) { | ||
initFlowRules(PUBLIC_RESOURCE); | ||
for (int i = 0; i < 13; i++) { | ||
|
||
Entry entry = null; | ||
try { | ||
entry = SphU.entry(PUBLIC_RESOURCE); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} finally { | ||
if (entry != null) { | ||
entry.exit(); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
private static void doSomething() { | ||
System.out.println("hello"); | ||
} | ||
} |
Oops, something went wrong.