Menu

  • Home
  • Work
    • Cloud
      • Virtualization
      • IaaS
      • PaaS
    • Java
    • Go
    • C
    • C++
    • JavaScript
    • PHP
    • Python
    • Architecture
    • Others
      • Assembly
      • Ruby
      • Perl
      • Lua
      • Rust
      • XML
      • Network
      • IoT
      • GIS
      • Algorithm
      • AI
      • Math
      • RE
      • Graphic
    • OS
      • Linux
      • Windows
      • Mac OS X
    • BigData
    • Database
      • MySQL
      • Oracle
    • Mobile
      • Android
      • IOS
    • Web
      • HTML
      • CSS
  • Life
    • Cooking
    • Travel
    • Gardening
  • Gallery
  • Video
  • Music
  • Essay
  • Home
  • Work
    • Cloud
      • Virtualization
      • IaaS
      • PaaS
    • Java
    • Go
    • C
    • C++
    • JavaScript
    • PHP
    • Python
    • Architecture
    • Others
      • Assembly
      • Ruby
      • Perl
      • Lua
      • Rust
      • XML
      • Network
      • IoT
      • GIS
      • Algorithm
      • AI
      • Math
      • RE
      • Graphic
    • OS
      • Linux
      • Windows
      • Mac OS X
    • BigData
    • Database
      • MySQL
      • Oracle
    • Mobile
      • Android
      • IOS
    • Web
      • HTML
      • CSS
  • Life
    • Cooking
    • Travel
    • Gardening
  • Gallery
  • Video
  • Music
  • Essay

Posts By Alex

Work

编程语言知识集锦

编程语言的分类

可以从多个角度划分编程语言的类别,一种语言同时可以属于多种分类。

从语言是否和体系结构紧密相连,编程语言可以分为:

  1. 低级语言:指机器语言或者汇编语言。这类语言不需要太多的编译步骤就可以被CPU执行
  2. 高级语言:其它语言都属于高级语言,高级语言高度封装…
阅读全文
12 years ago
0
Java

基于JavaConfig方式的Spring+Hibernate集成

JavaConfig类
包含Spring、Hibernate、事务管理等功能的样例
BeanDefinitionRegistrar.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package sparknet.wnet.saic.intf.spring;
 
import java.io.IOException;
import java.util.Properties;
 
import javax.inject.Inject;
import javax.sql.DataSource;
 
import net.greenmemory.breeze.persist.OracleProxoolDataSource;
import net.greenmemory.commons.db.QueryRunner;
import net.greenmemory.commons.lang.NumberUtils;
import net.greenmemory.spring.core.io.ClassPathResource;
 
import org.hibernate.SessionFactory;
import org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate3.HibernateTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource;
import org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor;
import org.springframework.transaction.interceptor.TransactionInterceptor;
 
import cc.gmem.tools.hibernatetools.spring.Hibernate3LocalSessionFactoryBean;
 
@Configuration
@ComponentScan (
        basePackages = { "cc.gmem.saic", "cc.gmem.intf" },
        excludeFilters = { @Filter ( type = FilterType.ANNOTATION, value = Configuration.class ) } )
@EnableAspectJAutoProxy
public class BeanDefinitionRegistrar
{
 
    @Inject
    private ApplicationContext applicationContext;
 
    @Bean ( name = "cfg" )
    public Properties getAppConfig()
    {
        Properties props = new Properties();
        try
        {
            props.load( new ClassPathResource( "wsi.properties" ).getInputStream() );
        }
        catch ( IOException e )
        {
            throw new BeanInitializationException( e.getMessage(), e );
        }
        return props;
    }
 
    @Bean ( name = "dataSource" )
    public DataSource getDataSource()
    {
        OracleProxoolDataSource dataSource = new OracleProxoolDataSource();
        dataSource.setAlias( getAppConfig().getProperty( "jdbc.alias" ) );
        dataSource.setDriver( getAppConfig().getProperty( "jdbc.driverClass" ) );
        dataSource.setDriverUrl( getAppConfig().getProperty( "jdbc.url" ) );
        dataSource.setUser( getAppConfig().getProperty( "jdbc.user" ) );
        dataSource.setPassword( getAppConfig().getProperty( "jdbc.password" ) );
        dataSource.setMinimumConnectionCount( NumberUtils.toInt( getAppConfig().getProperty( "jdbc.minimumConnectionCount" ), 10 ) );
        dataSource.setMaximumConnectionCount( NumberUtils.toInt( getAppConfig().getProperty( "jdbc.maximumConnectionCount" ), 100 ) );
        dataSource.setSimultaneousBuildThrottle( NumberUtils.toInt( getAppConfig().getProperty( "jdbc.simultaneousBuildThrottle" ), 50 ) );
        dataSource.setMaximumActiveTime( NumberUtils.toInt( getAppConfig().getProperty( "jdbc.maximumActiveTime" ), 1200000 ) );
        dataSource.setEncrypted( false );
        dataSource.init();
        return dataSource;
    }
 
    @Bean ( name = "sessionFactory" )
    public SessionFactory getSessionFactory() throws Exception
    {
        Hibernate3LocalSessionFactoryBean bean = new Hibernate3LocalSessionFactoryBean();
        bean.setApplicationContext( applicationContext );
        bean.setDataSource( getDataSource() );
        bean.setMappingResources( new String[] { "wnetJhInterface.hbm.xml" } );
        bean.setAutoRegister( true );
        Properties hibernateProperties = new Properties();
        hibernateProperties.setProperty( "hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect" );
        hibernateProperties.setProperty( "hibernate.jdbc.batch_size", "100" );
        hibernateProperties.setProperty( "hibernate.default_entity_mode", "dom4j" );
        hibernateProperties.setProperty( "hibernate.transaction.factory_class", "org.hibernate.transaction.JDBCTransactionFactory" );
        hibernateProperties.setProperty( "hibernate.current_session_context_class", "org.springframework.orm.hibernate3.SpringSessionContext" );
        bean.setHibernateProperties( hibernateProperties );
        bean.afterPropertiesSet();
        return bean.getObject();
    }
 
    @Bean ( name = "txManager" )
    public PlatformTransactionManager getTransactionManager() throws Exception
    {
        HibernateTransactionManager txMgr = new HibernateTransactionManager();
        txMgr.setSessionFactory( getSessionFactory() );
        return txMgr;
    }
 
    @Bean ( name = "jdbcTemplate" )
    public JdbcTemplate getJdbcTemplate()
    {
        return new JdbcTemplate( getDataSource() );
    }
 
    @Bean ( name = "queryRunner" )
    public QueryRunner getQueryRunner()
    {
        return new QueryRunner( getDataSource() );
    }
 
    @Bean
    public AnnotationTransactionAttributeSource transactionAttributeSource()
    {
        return new AnnotationTransactionAttributeSource();
    }
 
    @Bean
    public TransactionInterceptor transactionInterceptor() throws Exception
    {
        return new TransactionInterceptor( getTransactionManager(), transactionAttributeSource() );
    }
 
    @Bean
    public TransactionAttributeSourceAdvisor internalTransactionAdvisor() throws Exception
    {
        return new TransactionAttributeSourceAdvisor( transactionInterceptor() );
    }
 
    @Bean
    public InfrastructureAdvisorAutoProxyCreator internalAutoProxyCreator()
    {
        return new InfrastructureAdvisorAutoProxyCreator();
    }
}
初始化Spring ApplicationContext的代码
Java
1
2
ApplicationContext ctx = new AnnotationConfigApplicationContext(BeanDefinitionRegistrar.class);
DataSource ds= ctx.getBean(DataSource.class);
阅读全文
12 years ago
0
XML

XPath知识集锦

基础知识

XPath即为XML路径语言(XML Path Language),是一种用来确定XML文档中某部分位置的语言。在类似的语言,例如HTML中,XPath也被某些框架组件使用。

XPath表达式用于匹配XML节点或者节点集。它由 / 分隔的若干片断组成,每个片断都相对于其上下文节点来描述,片断可以包含:

  1. 轴描述:描述匹配节点…
阅读全文
12 years ago
0
Java

SpringMVC知识集锦

基于仿冒的SpringMVC测试用例示意
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package cc.gmem.demo.ctrl;
 
import static org.junit.Assert.*;
 
import javax.inject.Inject;
 
import net.greenmemory.commons.lang.StringUtils;
 
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
 
import com.fasterxml.jackson.databind.ObjectMapper;
 
@RunWith ( SpringJUnit4ClassRunner.class )
@ContextConfiguration ( locations = { "/spring-classgen-disabled.xml", "/spring-mvc.xml" } )
@TransactionConfiguration ( transactionManager = "txManager", defaultRollback = true )
public class SpringMVCControllerTest
{
    private static final org.slf4j.Logger LOGGER       = LoggerFactory.getLogger( SpringMVCControllerTest.class );
 
    @Inject
    private RequestMappingHandlerAdapter  handlerAdapter;
 
    @Inject
    private RequestMappingHandlerMapping  handlerMapping;
 
    @Inject
    private SessionFactory                sf;
 
    @Inject
    private ObjectMapper                  om;
 
    private MockHttpServletRequest        request;
 
    private MockHttpServletResponse       response;
 
    @Before
    @Transactional
    public void setUp()
    {
        request = new MockHttpServletRequest();
        response = new MockHttpServletResponse();
 
        Session sess = sf.getCurrentSession();
    }
 
    @Test
    @Transactional
    public void testController() throws Exception
    {
        request.setRequestURI( "/uri/" ); //设置请求的URI
        Object handler = handlerMapping.getHandler( request ).getHandler(); //获取Handler对象(就是控制器类)
        handlerAdapter.handle( request, response, handler ); //转发给Handler处理,并获取响应
        String contentType = response.getContentType();
        String json = response.getContentAsString();
        assertTrue( StringUtils.containsIgnoreCase( contentType, "json" ) );
        assertTrue( StringUtils.containsIgnoreCase( contentType, "utf-8" ) );
    }
}
常用问题
强制产生JSON格式的结果

配置 @RequestMapping( produces = "application/json" ) 

SpringMVC 设置 /* 过滤全部,导致JSP无法显示的问题
找不到控制器类的问题:No mapping found for HTTP request with URI
  1. 注意URL拦截的前置部分,如/admin,不要再控制器的映射路径中体现,例如地址/admin/user在控制器中直接配: /user
使用…
阅读全文
12 years ago
0
Gallery, Travel

2012年镇江金山游

阅读全文
12 years ago
0
1
Linux

控制组详解

简介
什么是Cgroups

控制组(Control Group)是Linux内核的一个特性,用于控制进程对CPU、磁盘I/O、内存、网络等资源的使用。Cgroup对进程(以及它们未来的子进程)进行分区/聚合,并关联到一个或者多个子系统。Cgroup子系统是一个模块,它利用Cgroup…

阅读全文
12 years ago
0
Java

Spring MVC 3.0学习笔记

Spring MVC框架简介
Spring MVC 3.0新特性
  1. 支持REST风格的URL
  2. 添加更多注解,可完全注解驱动
  3. 引入HTTP输入输出转换器(HttpMessageConverter)
  4. 和数据转换、格式化、验证框架无缝集成
  5. 对静态资源处理提供特殊支持 更加灵活…
阅读全文
12 years ago
0
Linux

Ubuntu下安装MySQL

Ubuntu 14.04
安装必要的软件
Shell
1
2
3
sudo apt-get install mysql-server
#修改root密码
mysqladmin -uroot -p原密码 password 新密码

注意,如果下载tar.gz的压缩包,需要手工进行数据库的初始化:

Shell
1
"scripts"/mysql_install_db --user=mysql --basedir=/var/mysql/ --datadir=/var/mysql/data/ --defaults-file=/path-to/my.cnf
修改配置文件
创建用户并授权
禁止开机启动
容器化

Dockerfile:

创建容器的命令:

 

 

阅读全文
12 years ago
0
Work

YAML快速参考

简介

YAML(发音/ˈjæməl/)的字面含义是另外一种标记语言(Yet Another Markup Language),实际上它不仅可以作为XML的替代品,更是一套支持所有编程语言的数据串行化标准。

语法
基本规则
  1. 大小写敏感
  2. 使用基于缩进的格式,缩进用来表示…
阅读全文
12 years ago
0
10
Linux

Linux目录层次和配置文件

/

唯一的根目录,没有Windows的盘符概念。根目录下的任何一个子目录都可以作为一个挂载点(mount point)来挂载某个文件系统(例如分区)。

/proc

即procfs,包含系统中正在运行的进程的映射文件,以及对应其它功能的若干子目录。

/proc/up…
阅读全文
13 years ago
0
更多文章

Recent Posts

  • Investigating and Solving the Issue of Failed Certificate Request with ZeroSSL and Cert-Manager
  • A Comprehensive Study of Kotlin for Java Developers
  • 背诵营笔记
  • 利用LangChain和语言模型交互
  • 享学营笔记
ABOUT ME

汪震 | Alex Wong

江苏淮安人,现居北京。目前供职于腾讯云,专注容器方向。

GitHub:gmemcc

Git:git.gmem.cc

Email:gmemjunk@gmem.cc@me.com

ABOUT GMEM

绿色记忆是我的个人网站,域名gmem.cc中G是Green的简写,MEM是Memory的简写,CC则是我的小天使彩彩名字的简写。

我在这里记录自己的工作与生活,同时和大家分享一些编程方面的知识。

GMEM HISTORY
v2.00:微风
v1.03:单车旅行
v1.02:夏日版
v1.01:未完成
v0.10:彩虹天堂
v0.01:阳光海岸
MIRROR INFO
Meta
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
Recent Posts
  • Investigating and Solving the Issue of Failed Certificate Request with ZeroSSL and Cert-Manager
    In this blog post, I will walk ...
  • A Comprehensive Study of Kotlin for Java Developers
    Introduction Purpose of the Study Understanding the Mo ...
  • 背诵营笔记
    Day 1 Find Your Greatness 原文 Greatness. It’s just ...
  • 利用LangChain和语言模型交互
    LangChain是什么 从名字上可以看出来,LangChain可以用来构建自然语言处理能力的链条。它是一个库 ...
  • 享学营笔记
    Unit 1 At home Lesson 1 In the ...
  • K8S集群跨云迁移
    要将K8S集群从一个云服务商迁移到另外一个,需要解决以下问题: 各种K8S资源的迁移 工作负载所挂载的数 ...
  • Terraform快速参考
    简介 Terraform用于实现基础设施即代码(infrastructure as code)—— 通过代码( ...
  • 草缸2021
    经过四个多月的努力,我的小小荷兰景到达极致了状态。

  • 编写Kubernetes风格的APIServer
    背景 前段时间接到一个需求做一个工具,工具将在K8S中运行。需求很适合用控制器模式实现,很自然的就基于kube ...
  • 记录一次KeyDB缓慢的定位过程
    环境说明 运行环境 这个问题出现在一套搭建在虚拟机上的Kubernetes 1.18集群上。集群有三个节点: ...
  • eBPF学习笔记
    简介 BPF,即Berkeley Packet Filter,是一个古老的网络封包过滤机制。它允许从用户空间注 ...
  • IPVS模式下ClusterIP泄露宿主机端口的问题
    问题 在一个启用了IPVS模式kube-proxy的K8S集群中,运行着一个Docker Registry服务 ...
  • 念爷爷
      今天是爷爷的头七,十二月七日、阴历十月廿三中午,老人家与世长辞。   九月初,回家看望刚动完手术的爸爸,发

  • 6 杨梅坑

  • liuhuashan
    深圳人才公园的网红景点 —— 流花山

  • 1 2020年10月拈花湾

  • 内核缺陷触发的NodePort服务63秒延迟问题
    现象 我们有一个新创建的TKE 1.3.0集群,使用基于Galaxy + Flannel(VXLAN模式)的容 ...
  • Galaxy学习笔记
    简介 Galaxy是TKEStack的一个网络组件,支持为TKE集群提供Overlay/Underlay容器网 ...
TOPLINKS
  • Zitahli's blue 91 people like this
  • 梦中的婚礼 64 people like this
  • 汪静好 61 people like this
  • 那年我一岁 36 people like this
  • 为了爱 28 people like this
  • 小绿彩 26 people like this
  • 彩虹姐姐的笑脸 24 people like this
  • 杨梅坑 6 people like this
  • 亚龙湾之旅 1 people like this
  • 汪昌博 people like this
  • 2013年11月香山 10 people like this
  • 2013年7月秦皇岛 6 people like this
  • 2013年6月蓟县盘山 5 people like this
  • 2013年2月梅花山 2 people like this
  • 2013年淮阴自贡迎春灯会 3 people like this
  • 2012年镇江金山游 1 people like this
  • 2012年徽杭古道 9 people like this
  • 2011年清明节后扬州行 1 people like this
  • 2008年十一云龙公园 5 people like this
  • 2008年之秋忆 7 people like this
  • 老照片 13 people like this
  • 火一样的六月 16 people like this
  • 发黄的相片 3 people like this
  • Cesium学习笔记 90 people like this
  • IntelliJ IDEA知识集锦 59 people like this
  • Bazel学习笔记 38 people like this
  • 基于Kurento搭建WebRTC服务器 38 people like this
  • PhoneGap学习笔记 32 people like this
  • NaCl学习笔记 32 people like this
  • 使用Oracle Java Mission Control监控JVM运行状态 29 people like this
  • 基于Calico的CNI 27 people like this
  • Ceph学习笔记 27 people like this
Tag Cloud
ActiveMQ AspectJ CDT Ceph Chrome CNI Command Cordova Coroutine CXF Cygwin DNS Docker eBPF Eclipse ExtJS F7 FAQ Groovy Hibernate HTTP IntelliJ IO编程 IPVS JacksonJSON JMS JSON JVM K8S kernel LB libvirt Linux知识 Linux编程 LOG Maven MinGW Mock Monitoring Multimedia MVC MySQL netfs Netty Nginx NIO Node.js NoSQL Oracle PDT PHP Redis RPC Scheduler ServiceMesh SNMP Spring SSL svn Tomcat TSDB Ubuntu WebGL WebRTC WebService WebSocket wxWidgets XDebug XML XPath XRM ZooKeeper 亚龙湾 单元测试 学习笔记 实时处理 并发编程 彩姐 性能剖析 性能调优 文本处理 新特性 架构模式 系统编程 网络编程 视频监控 设计模式 远程调试 配置文件 齐塔莉
Recent Comments
  • qg on Istio中的透明代理问题
  • heao on 基于本地gRPC的Go插件系统
  • 黄豆豆 on Ginkgo学习笔记
  • cloud on OpenStack学习笔记
  • 5dragoncon on Cilium学习笔记
  • Archeb on 重温iptables
  • C/C++编程:WebSocketpp(Linux + Clion + boostAsio) – 源码巴士 on 基于C/C++的WebSocket库
  • jerbin on eBPF学习笔记
  • point on Istio中的透明代理问题
  • G on Istio中的透明代理问题
  • 绿色记忆:Go语言单元测试和仿冒 on Ginkgo学习笔记
  • point on Istio中的透明代理问题
  • 【Maven】maven插件开发实战 – IT汇 on Maven插件开发
  • chenlx on eBPF学习笔记
  • Alex on eBPF学习笔记
  • CFC4N on eBPF学习笔记
  • 李运田 on 念爷爷
  • yongman on 记录一次KeyDB缓慢的定位过程
  • Alex on Istio中的透明代理问题
  • will on Istio中的透明代理问题
  • will on Istio中的透明代理问题
  • haolipeng on 基于本地gRPC的Go插件系统
  • 吴杰 on 基于C/C++的WebSocket库
©2005-2025 Gmem.cc | Powered by WordPress | 京ICP备18007345号-2