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 Nov 23, 2023
1 parent bdbeae5 commit 1af9e43
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/spring/cs4b476e90-89a4-11ee-9a0f-acde48001122.java
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.parsing;

/**
* @author Clinton Begin
*/
public interface TokenHandler {
String handleToken(String content);
}

65 changes: 65 additions & 0 deletions docs/spring/cs4b6e69fa-89a4-11ee-9a0f-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.huifer.data.queue;

/**
* <p>Title : RoundRobinQueue </p>
* <p>Description : 循环队列</p>
*
* @author huifer
* @date 2019-04-22
*/
public class RoundRobinQueue {

private Object[] queue;
private int queueSize;
// 头指针
private int front;
// 尾指针
private int rear;


public RoundRobinQueue(int queueSize) {
this.queueSize = queueSize;
this.front = 0;
this.rear = 0;
this.queue = new Object[queueSize];
}

public static void main(String[] args) {
RoundRobinQueue r = new RoundRobinQueue(3);
r.enqueue("元素1");
r.enqueue("元素2");
// 队列满
r.enqueue("元素3");
Object dequeue = r.dequeue();
System.out.println(dequeue.equals("元素1"));
}


/**
* 是否满队列
*/
public boolean isFull() {
return (rear + 1) % queue.length == front;
}

public boolean enqueue(Object obj) {
if (isFull()) {
return false;
}
queue[rear] = obj;
rear = (rear + 1) % queue.length;
return true;
}


public Object dequeue() {
if (rear == front) {
return null;
}
Object obj = queue[front];
front = (front + 1) % queue.length;
return obj;
}


}
70 changes: 70 additions & 0 deletions docs/spring/cs4b954cd2-89a4-11ee-9a0f-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.huifer.idgen.my.service.conv;

import com.huifer.idgen.my.service.bean.Id;
import com.huifer.idgen.my.service.bean.IdMeta;
import com.huifer.idgen.my.service.bean.enums.IdType;
import com.huifer.idgen.my.service.factory.IdMetaFactory;

/**
* @author: wang
* @description:
*/
public class IdConverterImpl implements IdConverter {

private IdMeta idMeta;

public IdConverterImpl(IdType idType) {
this(IdMetaFactory.getIdMeta(idType));
}

public IdConverterImpl(IdMeta idMeta) {
this.idMeta = idMeta;
}


@Override
public long converter(Id id) {
return doConverter(id, this.idMeta);
}

@Override
public Id converter(long id) {
return doConvert(id, idMeta);
}

/**
* 根据id生产,根据id元数据生产一个long类型的id
*
* @param id
* @param idMeta
* @return
*/
protected long doConverter(Id id, IdMeta idMeta) {
long res = 0;
res |= id.getMachine();
res |= id.getSeq() << idMeta.getMachineBits();
res |= id.getTime() << idMeta.getTimeBitsStartPos();
res |= id.getGenMethod() << idMeta.getGenMethodBitsStartPos();
res |= id.getType() << idMeta.getTypeBitsStartPos();
res |= id.getVersion() << idMeta.getVersionBitsStartPos();
return res;
}

/**
* 根据long类型id,根据id元数据返回这个id的意义
*
* @param id
* @param idMeta
* @return
*/
protected Id doConvert(long id, IdMeta idMeta) {
Id res = new Id();
res.setMachine(id & idMeta.getMachineBitsMask());
res.setSeq((id >>> idMeta.getMachineBits()) & idMeta.getSeqBitsMask());
res.setTime((id >>> idMeta.getTimeBitsStartPos()) & idMeta.getTimeBitsMask());
res.setGenMethod((id >>> idMeta.getGenMethodBitsStartPos()) & idMeta.getGenMethodBitsMask());
res.setType((id >>> idMeta.getTypeBitsStartPos()) & idMeta.getTypeBitsMask());
res.setVersion((id >>> idMeta.getVersionBitsStartPos()) & idMeta.getVersionBitsMask());
return res;
}
}
12 changes: 12 additions & 0 deletions docs/spring/cs4bcacb5a-89a4-11ee-9a0f-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.huifer.design.singleton.nw;


public class SimpleSingletonTest {
public static void main(String[] args) {
Thread t1 = new Thread(new ExecutorThread());
Thread t2 = new Thread(new ExecutorThread());
t1.start();
t2.start();
System.out.println("结束");
}
}
35 changes: 35 additions & 0 deletions docs/spring/cs4bf4ae70-89a4-11ee-9a0f-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.huifer.design.proxy.cglib;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
* <p>Title : CGLIBZhiLian </p>
* <p>Description : </p>
*
* @author huifer
* @date 2019-05-17
*/
public class CGLIBZhiLian {

public Object getInstance(Class<?> clazz) throws Exception {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(clazz);

enhancer.setCallback(new MethodInterceptor() {
@Override
public Object intercept(Object o, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
System.out.println("CGLIB 代理智联");
Object o1 = methodProxy.invokeSuper(o, args);
return o1;
}
});

return enhancer.create();

}
}

0 comments on commit 1af9e43

Please sign in to comment.