??xml version="1.0" encoding="utf-8" standalone="yes"?>国产成A人亚洲精V品无码 ,久久精品国产精品亚洲蜜月,亚洲国产精品成人http://m.tkk7.com/bjwulin/正在行走的h...zh-cnSun, 11 May 2025 10:22:00 GMTSun, 11 May 2025 10:22:00 GMT60ubuntu server下安装apache,mysql,tomcat?/title><link>http://m.tkk7.com/bjwulin/archive/2014/02/19/410032.html</link><dc:creator>不做躁的h</dc:creator><author>不做躁的h</author><pubDate>Wed, 19 Feb 2014 05:04:00 GMT</pubDate><guid>http://m.tkk7.com/bjwulin/archive/2014/02/19/410032.html</guid><wfw:comment>http://m.tkk7.com/bjwulin/comments/410032.html</wfw:comment><comments>http://m.tkk7.com/bjwulin/archive/2014/02/19/410032.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/bjwulin/comments/commentRss/410032.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/bjwulin/services/trackbacks/410032.html</trackback:ping><description><![CDATA[一直想用nginxQ因Z说很快,可惜对f4f只在商用中支持,所以,暂时攑ּQ还是l用用apache?br />1、安装apache很简单,先例行公事:sudo apt-cache search apache|grep apacheQ查扑ֈ里面的apache2Q执行sudo apt-get install apache2Q很快就安装完,安装完后执行http://127.0.0.1Q如果出现it works,那就表示安装正确?br />备注QApache的默认文根目录是在Ubuntu上的/var/www目录Q配|文件是 /etc/apache2/apache2.conf。配|存储的子目录在/etc/apache2目录Qapache重启命oQsudo /etc/init.d/apache2 restart<br /><br />2、安装mysql也很单,先例行公事:sudo apt-cache search mysql|grep serverQ可以看到里面的mysql-server后面跟着"metapackage depending on the latest version"Q因此直接安装mysql-server可以获得最新版本。执行:sudo apt-get install mysql-server mysql-clientQ安装完后执行mysql -uroot -pQ输入默认密码rootQ即可登录mysql client的操作界面?br />mysql默认配置文g路径Q?etc/mysql/my.cnf<br /><br />3、安装tomcat7Q例行公事:sudo apt-cache search tomcat7Q然后执行sudo apt-get install tomcat7 tomcat7-admin。安装完毕后Q在览器输入http://127.0.0.1:8080Q出现it works...表示你成功了?br />备注Qtomcat7一般放?var/lib/tomcat7/webapps?br /><br />4、整合apache2和tomcat7<br />a、安装mod-jk,sudo apt-get install libapache2-mod-jk <br />b、编辑tomcat配置文gQsudo nano /etc/tomcat7/server.xml Q讲”<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />“的注释去掉?br />c、在/etc/apache2/下新建workers.propertiesQsudo nano /etc/apache2/workers.properties,输入以下内容Q?br /><div>worker.list=worker1 <br /><br />worker.worker1.type=ajp13 <br />worker.worker1.host=localhost<br />worker.worker1.port=8009<br />d、编辑jk.conf文gQ执行sudo nano /etc/apache2/mods-enabled/jk.conf。将JkWorkersFile修改为:/etc/apache2/workers.properties<br />e、最后配|{发\径,即符合规则的路径由apache转发ltomcat7。编?00-default.conf文gQ执行:sudo nano /etc/apache2/sites-enabled/000-default.confQ在该文件中增加Q?br /><div><VirtualHost *:80><br />...<br />JkMount /tomcat-test* worker1<br /></VirtualHost *:80><br />x配置都完了。我们用?tomcat-test*Q表C问这个webapp时{发给worker1q行处理Q因此我们还需要做一个tomcat-test应用来进行测试?br />f、我们在/var/lib/tomcat7/webapps建立一个测试appQ依ơ执行命令:cd /var/lib/tomcat7/webappsQsudo mkdir tomcat-test Q?cd tomcat-test Q?br /><div>sudo mkdir test Q?cd test Q?sudo nano index.jspQƈ在index.jsp文g中输入以下内容:</div><div><HTML><br /> <HEAD><br />  <TITLE>Hello World</TITLE><br /> </HEAD><br /> <BODY><br />  <H1>Hello World</H1><br />  Today is: <%= new java.util.Date().toString() %><br /> </BODY><br /></HTML></div>在浏览器中输入:http://192.168.1.10:8080/tomcat-test/test/index.jspQ验证是否正常?br /><br />g、重启tomcat7和apache2Q执行命令:sudo /etc/init.d/tomcat7 restart和sudo /etc/init.d/apache2 restartQ然后在览器中输入Q?div>http://192.168.1.10/tomcat-test/test/index.jspQ验证是否正常?/div><br /></div></div><br /><br /><img src ="http://m.tkk7.com/bjwulin/aggbug/410032.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/bjwulin/" target="_blank">不做躁的h</a> 2014-02-19 13:04 <a href="http://m.tkk7.com/bjwulin/archive/2014/02/19/410032.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>redis 生环境中的自动启动http://m.tkk7.com/bjwulin/archive/2014/02/19/410019.html不做躁的h不做躁的hWed, 19 Feb 2014 02:39:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/19/410019.htmlhttp://m.tkk7.com/bjwulin/comments/410019.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/19/410019.html#Feedback0http://m.tkk7.com/bjwulin/comments/commentRss/410019.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/410019.html2、徏立需要的文g夹,我们一般需?etc/redisQ用来存放redis的配|文Ӟ以及/var/redis/6000Q存放redis的持久文Ӟ?br />3、将解压的redis目录下的redis.conf拯?etc/redisQƈ命名为redis_6000.confQƈ对以下参数进行修?
    daemonize 修改为yesQ确保redis以守护进E模式运行?br />    pidfile 修改?var/run/redis_6000.pid
    port修改?000
    dir修改?var/redis/6000
    定两个目录都存在?br />4、执行:/etc/init.d/redis_6000 start启动redisQ再执行sudo update-rc.d redis_6000 defaults?br />
完毕?img src ="http://m.tkk7.com/bjwulin/aggbug/410019.html" width = "1" height = "1" />

不做躁的h 2014-02-19 10:39 发表评论
]]>
thymeleaf与spring整合http://m.tkk7.com/bjwulin/archive/2014/02/11/409734.html不做躁的h不做躁的hTue, 11 Feb 2014 08:16:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/11/409734.htmlhttp://m.tkk7.com/bjwulin/comments/409734.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/11/409734.html#Feedback0http://m.tkk7.com/bjwulin/comments/commentRss/409734.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409734.html2、访问上下文的Bean?{@myBean.doSomething()}
3、th:field,th:errors,th:errorclass用于form processing?br />4、要采用SpringTemplateEngine?br />5、基本配|:
<bean id="templateResolver"
       class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
  <property name="prefix" value="/WEB-INF/templates/" />
  <property name="suffix" value=".html" />
  <property name="templateMode" value="HTML5" />
</bean>
    
<bean id="templateEngine"
      class="org.thymeleaf.spring3.SpringTemplateEngine">
  <property name="templateResolver" ref="templateResolver" />
</bean>

<bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
  <property name="templateEngine" ref="templateEngine" />
  <property name="order" value="1" />
  <property name="viewNames" value="*.html,*.xhtml" />
</bean>

6、被@ModelAttribute注释的方法会在此controller每个Ҏ执行前被执行Q如果@ModelAttribute注释的方法有q回|则表C在model中存N含名U的属性对象,比如q回AccountQ则相当于model.addAttribute("account",account)Q如果@ModelAttribute(value="aname")注释ҎQ则表示在model中增加aname的属性倹{@ModelAttribute注释一个方法的参数则表CZmodel中或者从Form表单或者url中获取?br />7?@RequestMapping("/hello")public void novoid() { }Q返回视图ؓ前缀+/hello+后缀Q当Ҏq回Map,ModelMap{时都是相当于Request.setAttribute()?br />8?lt;td th:text="${{sb.datePlanted}}">13/01/2011</td>双括可C动用{换,常用于格式{换?br />9?lt;td th:text="${#strings.arrayJoin(#messages.arrayMsg(#strings.arrayPrepend(sb.features,'seedstarter.feature.')),', ')}">Electric Heating, Turf</td>Q首先将数组feathers都加上前~Q然后利用messages译国际化,最l组合成一个字W串?br />10、用th:object指定command objectQ比如:<form action="#" th:action="@{/save}" th:object="${person}" method="post">Q两炚wӞW一object只能是model 的直接attributeQ不能${person.baseInfo},W二Qth:object的子U标{ֆ不能再用th:object。inputField使用Q?lt;input type="text" th:field="*{datePlanted}" />?br />12、checkbox标签Q?div><div>
  <label th:for="${#ids.next('covered')}" th:text="#{seedstarter.covered}">Covered</label>
  <input type="checkbox" th:field="*{covered}" />
</div>
checkbox array:
<ul>
  <li th:each="feat : ${allFeatures}">
    <input type="checkbox" th:field="*{features}" th:value="${feat}" />
    <label th:for="${#ids.prev('features')}" th:text="#{${'seedstarter.feature.' + feat}}">Heating</label>
  </li>
</ul>

13、radios:
<ul>
  <li th:each="ty : ${allTypes}">
    <input type="radio" th:field="*{type}" th:value="${ty}" />
    <label th:for="${#ids.prev('type')}" th:text="#{${'seedstarter.type.' + ty}}">Wireframe</label>
  </li>
</ul>

14、dropdownlist or select?br />
<select th:field="*{type}">
  <option th:each="type : ${allTypes}"
          th:value="${type}"
          th:text="#{${'seedstarter.type.' + type}}">Wireframe</option>
</select>

15、预处理Q?lt;select th:field="*{rows[__${rowStat.index}__].variety}">而不使用<select th:field="*{rows[rowStat.index].variety}">Q因为spring el不会计算数组索引中的变量或者表辑ּ?br />16、错误显C:<input type="text" th:field="*{datePlanted}" th:class="${#fields.hasErrors('datePlanted')}? fieldError" />
<ul>
  <li th:each="err : ${#fields.errors('datePlanted')}" th:text="${err}" />
</ul>

<input type="text" th:field="*{datePlanted}" />
<p th:if="${#fields.hasErrors('datePlanted')}" th:errors="*{datePlanted}">Incorrect date</p>

<input type="text" th:field="*{datePlanted}" class="small" th:errorclass="fieldError" />

<ul th:if="${#fields.hasErrors('*')}">
  <li th:each="err : ${#fields.errors('*')}" th:text="${err}">Input is incorrect</li>
</ul>
全局错误Q?br />
<ul th:if="${#fields.hasErrors('global')}">
  <li th:each="err : ${#fields.errors('global')}" th:text="${err}">Input is incorrect</li>
</ul>
在form外显C错?
<div th:errors="${myForm}">...</div>
<div th:errors="${myForm.date}">...</div>
<div th:errors="${myForm.*}">...</div>

<div th:if="${#fields.hasErrors('${myForm}')}">...</div>
<div th:if="${#fields.hasErrors('${myForm.date}')}">...</div>
<div th:if="${#fields.hasErrors('${myForm.*}')}">...</div>

<form th:object="${myForm}">
    ...
</form>
17、利用功能类转换Q?conversions.convert(Object,Class)Q?conversions.convert(Object,String)
18、渲染模板的片段Q常用于ajaxQ返回一部分文本做替换用?br />在ViewBean中指定片D:
<bean name="content-part" class="org.thymeleaf.spring3.view.ThymeleafView">
  <property name="templateName" value="index" />
  <property name="fragmentSpec">
    <bean class="org.thymeleaf.standard.fragment.StandardDOMSelectorFragmentSpec"
          c:selectorExpression="content" />
  </property>
</bean>

@RequestMapping("/showContentPart")
public String showContentPart() {
    ...
    return "content-part";//q回上面定义的bean名称?br />}
c:selectorExpression="content"Q需要在content节点加上th:fragment?/div>c:selectorExpression="#content" Q完全基于html dom selectorQ无需th:fragment?br />在controller中指定片D:
@RequestMapping("/showContentPart")
public String showContentPart() {
    ...
    return "index :: content";
}
"index :: content"?index ::#content"区别一栗?br />q可以返回带参数的片D:
@RequestMapping("/showContentPart")
public String showContentPart() {
    ...
    return "index :: #content ('myvalue')";
}










不做躁的h 2014-02-11 16:16 发表评论
]]>
面布局备忘http://m.tkk7.com/bjwulin/archive/2014/02/10/409656.html不做躁的h不做躁的hMon, 10 Feb 2014 06:00:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/10/409656.htmlhttp://m.tkk7.com/bjwulin/comments/409656.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/10/409656.html#Feedback1http://m.tkk7.com/bjwulin/comments/commentRss/409656.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409656.html
thymeleaf的eclipse插gQhttps://github.com/thymeleaf/thymeleaf-extras-eclipse-plugin

面布局分ؓ包含布局和层ơ布局Q包含布局Q一般通过th:include以及th:replace来实玎ͼinclude和replace不一L是一个包含在host tag里面Q一个是指替换host tagQthymeleaf的包含布局和jsp的include不同的方面在于,thymeleaf可以包含某个文g的某一个部分,而jsp的必d含整个文件。比如:<div th:replace="fragments/header :: header">...</div>Qfragments/header是指被包含的模板文gQ?:header的header指被包含模板文g中的被包含部分。可以用this:header或?:header都是指包含本面的部分。被包含的文件的被包含部分需要加上属性:th:fragment="header"

thymeleaf可以Zdom selector来处理包含,而不用显C地调用th:fragmentQ比如:<div th:include="http://www.thymeleaf.org :: p.notice" >...</div>Q那么将会调用tag p?class="notice“的片D,q个最大的好处是包含别的|站的网部分。以前的做法有用ajax的,有用iframe的,q有用javabean获取后传l前端的。thymeleafq种处理方式相对合理。采用domq种方式Q需要templateEngine.addTemplateResolver(urlTemplateResolver());

包含语法的模板文件和片段都可以通过表达式来指定Q比?lt;div th:replace="fragments/footer :: ${#authentication.principal.isAdmin()} ? 'footer-admin' : 'footer'">?br />
thymeleaf包含模板也支持参数包含,比如Q?br />
<div th:fragment="alert (type, message)"
         class="alert alert-dismissable" th:classappend="'alert-' + ${type}">
      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
      <span th:text="${message}">Test</span>
    </div>
表示alertq个片段有两个参敎ͼtype和messageQ那么调用的时候:
<div th:replace="fragments/alert :: alert (type='danger', message=${errorMessage})">...</div>
参数化片D|高片D늚可重用?

题外话,我当q特喜欢infoglue的设计理念,事过好多q_依稀记得slot和param binding两个让我一直很喜欢的理念,现在的thymeleaf都可以做到。l?..

能够从spring controllerq回片段Q比如:
if (AjaxUtils.isAjaxRequest(requestedWith)) {
        return SIGNUP_VIEW_NAME.concat(" :: signupForm");
    }
    return SIGNUP_VIEW_NAME;
当用ajaxh的时候,后端q回的视图ؓ片段的内宏V?br />
包含布局Q由于是在每个页面包含公׃码,因此naturalҎ没有媄响,不过如果一旦需要切换包含另外的公共部分或者改变统一面布局模式Q那么包含布局显得力不从心。层ơ布局Q目前流行的有Tiles和sitemeshQ一般是布局{公用部分放在parent里面Q显C时每个子面的具体内容融合到parent里面来对外展玎ͼ优点是更好的l护性,~点是natural不够?br />
本次信息发布内核采用层次布局模式。两层模板展玎ͼ父模板负责布局展现Q子U模板负责内容展现?br />针对spring mvc和thymeleaf做一下扩展:
1、定义注释:layout注释可以用在cdҎ上?br />
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Layout {
    String value() default "";
}

2、定义interceptorQ?br />
public class ThymeleafLayoutInterceptor extends HandlerInterceptorAdapter {
 
    private static final String DEFAULT_LAYOUT = "layouts/default";
    private static final String DEFAULT_VIEW_ATTRIBUTE_NAME = "view";
 
    private String defaultLayout = DEFAULT_LAYOUT;
    private String viewAttributeName = DEFAULT_VIEW_ATTRIBUTE_NAME;
 
    public void setDefaultLayout(String defaultLayout) {
        Assert.hasLength(defaultLayout);
        this.defaultLayout = defaultLayout;
    }
 
    public void setViewAttributeName(String viewAttributeName) {
        Assert.hasLength(defaultLayout);
        this.viewAttributeName = viewAttributeName;
    }
 
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (!modelAndView.hasView()) {
            return;
        }
        String originalViewName = modelAndView.getViewName();
        if (isRedirectOrForward(originalViewName)) {
            return;
        }
        String layoutName = getLayoutName(handler);
        modelAndView.setViewName(layoutName);
        modelAndView.addObject(this.viewAttributeName, originalViewName);
    }
 
    private boolean isRedirectOrForward(String viewName) {
        return viewName.startsWith("redirect:") || viewName.startsWith("forward:");
    }
 
    private String getLayoutName(Object handler) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Layout layout = getMethodOrTypeAnnotation(handlerMethod);
        if (layout == null) {
            return this.defaultLayout;
        } else {
            return layout.value();
        }
    }
 
    private Layout getMethodOrTypeAnnotation(HandlerMethod handlerMethod) {
        Layout layout = handlerMethod.getMethodAnnotation(Layout.class);
        if (layout == null) {
            return handlerMethod.getBeanType().getAnnotation(Layout.class);
        }
        return layout;
    }
}

3Q配|interceptorQ?br />
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ThymeleafLayoutInterceptor());
    }
}

4Q测试类Q?br />
@Controller
class SigninController {
 
    @Layout(value = "layouts/blank")
    @RequestMapping(value = "signin")
    String signin() {
        return "signin/signin";
    }
}
5Q测试布局模板面Q?br />
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
 
<head>...</head>
<body>
<div th:raplace="fragments/header :: header">
    Header
</div>
<div th:replace="${view} :: content">
    Content
</div>
<div th:replace="fragments/footer :: footer">
    Footer
</div>
</body>
</html>


6Q测试内Ҏ杉K面:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
 
<head>...</head>
<body>
<div class="container" th:fragment="content">
    <!-- /* Handle the flash message */-->
    <th:block th:if="${message != null}">
        <div th:replace="fragments/alert :: alert (type=${#strings.toLowerCase(message.type)}, message=${message.message})"> </div>
    </th:block>
    <p>
        Hello <span th:text="${#authentication.name}">User</span>!
        Welcome to the Spring MVC Quickstart application!
    </p>
</div>
</body>
</html>


不做躁的h 2014-02-10 14:00 发表评论
]]>
redis学习备忘http://m.tkk7.com/bjwulin/archive/2014/02/08/409621.html不做躁的h不做躁的hSat, 08 Feb 2014 10:51:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/08/409621.htmlhttp://m.tkk7.com/bjwulin/comments/409621.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/08/409621.html#Feedback0http://m.tkk7.com/bjwulin/comments/commentRss/409621.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409621.html
spring data redis推荐jedisQ因此稍微把jedisE微看了下,jedis是redis的java客户端?br />
sdr支持低层ơ的通过q接器connectorq接到RedisQ支持高层次的友好的模板cRedisTemplate,RedisTemplate是徏立在低别的connection基础之上。RedisConnection接收或返回字节数l需要自w处理连接,比如关闭q接Q而RedisTemplate负责处理串行化和反串行化Qƈ且管理对q接q行理。RedisTemplate提供操作视图Q比?Bound)ValueOperations,
(Bound)ListOperations,(Bound)SetOperations,(Bound)ZSetOperations,(Bound)HashOperations。RedisTemplate是线E安全的Q能够用于多个实例中?/div>
RedisTemplate默认选择java-based串行?也可以切换ؓ其它的串行化方式Q或者设|enabledDefaultSerializer为false或者设|串行化器ؓnullQ则RedisTemplate用raw byte arrays表示数据?br />
sdrq接到redis通过RedisConnectionFactory来获得有效的RedisConnection。RedisConnection负责建立和处理和redis后端通信。RedisConnection提供getNativeconnectionq回用来通信的底层connection?br />
spring配置Q?br />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:p="http://www.springframework.org/schema/p"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
        p:host-name="server" p:port="6379" p:use-pool="true"/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
    p:connection-factory-ref="jedisConnectionFactory"/>
</beans>

使用样例Q?br />
public class Example {

  // 注入实际的模?br />  @Autowired
  private RedisTemplate<String, String> template;//表示键值都是字W串cd?br />
  // 注入模板为ListOperations.
  @Resource(name="redisTemplate")
  private ListOperations<String, String> listOps;

  public void addLink(String userId, URL url) {
    listOps.leftPush(userId, url.toExternalForm());
  }
}

׃大部分Redis键值对存储都是键值均为字W串Q因此sdr做了两个扩展Q即StringRedisConnection以及StringRedisTemplateQ两个扩展均采用StringRedisSerializer?br />
<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"
    p:connection-factory-ref="jedisConnectionFactory"/>

代码CZQ?br />
@Autowired
  private StringRedisTemplate redisTemplate;

  public void addLink(String userId, URL url) {
    redisTemplate.opsForList().leftPush(userId, url.toExternalForm());
  }

RedisTemplate以及其子c都允许开发者通过RedisCallback直接跟Redis通信Q在callback中,开发者获得RedisConnection。StringRedisTemplate在callback中可以获得StringRedisConnectionQ需要强制{换?br />
利用Redis实现Jms的发布和订阅的功能:
发布信息Q可以通过RedisConnection或者RedisTemplate来实现?br />redisConnection.publish(byte[] msg,byte[] channel);
template.convertAndSend("hello!","world");
接收消息Q在接受放,可以订阅Ҏ频道名来订阅一个或多个频道或者通过模式匚w。模式匹配非常有用,因ؓ它不仅允怸个命令创建多个订阅,也能监听在订阅创Z后生的新的频道Q只要匹配指定的模式Q?br />在低层面上,RedisConnection提供subscribe和pSubscribeQ根据模式匹配)ҎQ多个频道和模式可以一起作为参敎ͼRedisConnection也提供了getSubscription和isSubscribedҎ。当用jedisq接器时Q订阅命令是同步的,因此会生堵塞,会导致该U程一直等待消息,只有当订阅取消的时候,才释攄E,采用unsubcribe或pUnsubscribe来取消同U程的订阅。ؓ了处理订阅消息,需要实现MessageListener callbackQ每ơ当新的消息辑ֈӞ会调用callback执行onMessageҎQ该Ҏ能够获得消息Q频道,以及匚w的模式?br />
׃MessageListener的天然堵塞,底层面的消息接收不太被h接受Q而且它要求处理连接和U程的管理,Z规避q个问题Qsdr提供RedisMessageListenerContainer,它被用来接受从Redis频道传来的消息ƈ注入MessageListener,RedisMessageListenerContainer负责相应接受消息的线Eƈz֏到处理的监听器中?br />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:redis="http://www.springframework.org/schema/redis"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/redis http://www.springframework.org/schema/redis/spring-redis.xsd">

  <!-- the default ConnectionFactory -->
  <redis:listener-container>
    <!-- the method attribute can be skipped as the default method name is "handleMessage" -->
    <redis:listener ref="listener" method="handleMessage" topic="chatroom" />
  </redis:listener-container>
 
  <bean id="listener" class="redisexample.DefaultMessageDelegate"/>
  ...
<beans>

redis对事务提供支持,包括multi,exec,discard命oQ这些命令也能用于RedisTemplateQ然后redisTemplate不保证用相同的连接在同一个事务执行所有操作。sdr提供SessionCallback接口用于同线E的多操作执行?br />
Redis支持道Qpipelining),道可以发送多个命令到服务端无需{待反馈然后d单一步的反馈。管道在你需要一行发送多个命令是提升性能Q比如对相同的列表增加多个元素。如果不x道操作的结果,则可以调用RedisTemplate标准的excuteҎQ传递true作ؓpipeline参数。excutePipelinedҎ执行RedisCallback或者sessionCallbackQ然后返回结果?br />
List<Object> results = stringRedisTemplate.executePipelined(new RedisCallback<Object>() {
    public Object doInRedis(RedisConnection connection) throws DataAccessException {
        StringRedisConnection stringRedisConn = (StringRedisConnection)connection;
        for(int i=0; i< batchSize; i++) {
            stringRedisConn.rPop("myqueue");
        }
        return null;//必须q回null
    }
});//results为myqueue的value?br />
Redis2.6以及更高的版本支持通过eval和evalsha命o执行lua script。sdr装代码执行Q串行化以及利用代码~存。scripts能够通过RedisTemplate的executeҎ来运行,RedisTemplate用一个可配置的ScriptExecutor来执行提供的代码。缺省的ScriptExecutor通过获取代码的sha1Q尝试运行evalshaQ失败后执行eval?br />
lua script一般用于原子操作且命o的行另外的命令结果所影响?br />
配置Q?br />
<bean id="script" class="org.springframework.data.redis.core.script.DefaultRedisScript">
        <property name="location" value="classpath:META-INF/scripts/checkandset.lua"/>
        <property name="resultType" value="java.lang.Boolean"/>
    </bean>

java代码Q?br />
@Autowired
    RedisScript<Boolean> script;

    public boolean checkAndSet(String expectedValue, String newValue) {
        return redisTemplate.execute(script, Collections.singletonList("key"),
            expectedValue, newValue);
    }

lua script:
-- checkandset.lua
local current = redis.call('GET', KEYS[1])
if current == ARGV[1]
then
    redis.call('SET', KEYS[1], ARGV[2])
    return true
end
return false
redis支持cd攑֜org.springframework.data.redis.supportQRedisSet和RedisZSet提供Redis支持的intersection以及union{方法。RedisList可以实现Queue以及Deque来实现FIFO和LiFO?br />配置Q?br />
<bean id="queue" class="org.springframework.data.redis.support.collections.DefaultRedisList">
    <constructor-arg ref="redisTemplate"/>
    <constructor-arg value="queue-key"/>
  </bean>
代码Q?br />
// injected
  private Deque<String> queue;

  public void addTag(String tag) {
    queue.push(tag);
  }

Sdr提供了一个spring3.1 cache abstraction的实现。配|:
<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:template-ref="redisTemplate"/>







不做躁的h 2014-02-08 18:51 发表评论
]]>maven学习备忘http://m.tkk7.com/bjwulin/archive/2014/02/08/409611.html不做躁的h不做躁的hSat, 08 Feb 2014 05:39:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/08/409611.htmlhttp://m.tkk7.com/bjwulin/comments/409611.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/08/409611.html#Feedback0http://m.tkk7.com/bjwulin/comments/commentRss/409611.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409611.html
于是Q一直在排斥mavenQ不愿意学习Q于是对于maven始终是菜鸟,现在来多的项目都开始用mavenQ于是,不愿意还是maven白Q选择学习Q选择备忘q个学习q程?br />
eclipse indigo安装m2eQ选择安装路径为:http://download.eclipse.org/releases/indigoQ然后选择m2eQ新的m2e版本不能在indigo安装Q安装完后,在eclipse 的reference里面讄maven的installations以及user settingQ改变里面的setting文g为安装目录\conf\settings.xml文gQƈ改变该文件中的本C库\?lt;localRepository>?/div>
下蝲mvnQ然后设定系lpathQ设|MAVEN_OPTS的gؓQ?Xms128m -Xmx512m{就不用啰嗦了。先看一个命令,入个门:
mvn archetype:create -DgroupId=com.studio -DartifactId=helloWorld -DpackageName=com.studymaven
archetype是mvn的一个插Ӟplugin),create是archetype的一个Q务(taskQ?D后面的是q个d的参数。groupId一般是开发组l的IdQartifactId是本目的具体名U?

mvn插g有哪些Q务,可以用mvn help:describe -Dplugin=archetypeQhelp是插Ӟdescribe是help的Q务,整个命o昄archetype的所有Q务信息,如要查看详细的参C息,则加?Dfull参数?br />
mvn的命令支持简写,比如mvn compile=mvn compile:compileQ另外常用的写命令有Qmvn compile Qmvn test-compileQmvn testQmvn packageQmvn install 应用发布到本地仓库Qmvn deploy 复制最l的包至q程仓库Q共享给其它开发h员和目供其他项目用?br />
maven采用坐标_定位每一个构建(artifect)Q也是通过一些参数精找到合适的jar包?/div>
mvn archetype:generate命o可以以提C的方式填写created的参敎ͼ生成完毕后,可以通过m2e导入到eclipseQ或者直接在eclipse中徏立maven projectQ选择maven-archetype-quickstart?br />
当用eclipse建立目后,可以选择目的pom.xmlQ然后run asQ选择合适的命oQ如果没有合适的命oQ则可以通过选择Maven buid… 自定义Mavenq行命oQ在弹出对话框中的Goals一中输入我们惌执行的命令?br />
最后一点,我们更多时候需要源代码包,那么可以选择需要源代码的jarQ然后右键,然后mavenQ然后Download source卛_?br />


不做躁的h 2014-02-08 13:39 发表评论
]]>flex mobile开发的一些注意点http://m.tkk7.com/bjwulin/archive/2014/02/07/409562.html不做躁的h不做躁的hThu, 06 Feb 2014 16:20:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/07/409562.htmlhttp://m.tkk7.com/bjwulin/comments/409562.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/07/409562.html#Feedback0http://m.tkk7.com/bjwulin/comments/commentRss/409562.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409562.html2、每个View都有createReturnObject()Q复写该ҎQ可以ؓ上一个视囑ֱ现提供数据,上一个视囑֏以采用:navigator.poppedViewReturnedObject.object来得到数据?br />3、如果需要在应用E序q行期间保存数据Q则需要设|应用的persistNavigatorState属性,q且~写navigatorStateLoading ?navigatorStateSaving两个旉的处理方法?br />4、flex mobile不能使用mx AlertQ也不能使用spark AlertQ官方徏议用SkinnablePopUpContainer?br />5、可以用fx:Component className="AlertMsg"嵌套定义lgcR通过new AlertMsg()来生成实例?br />

不做躁的h 2014-02-07 00:20 发表评论
]]>
flex mobile适应讑֤寸http://m.tkk7.com/bjwulin/archive/2014/02/06/409558.html不做躁的h不做躁的hThu, 06 Feb 2014 11:26:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/02/06/409558.htmlhttp://m.tkk7.com/bjwulin/comments/409558.htmlhttp://m.tkk7.com/bjwulin/archive/2014/02/06/409558.html#Feedback0http://m.tkk7.com/bjwulin/comments/commentRss/409558.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409558.html
flex sdk4.5及以上在Application及其子类上提供了ApplicationDpiQƈ支持3U类型的dpiQ?60,240,320Q基本上可以늛目前已有的设备的dpi?br />
如果讑֮Application的applicationDpiQflex runtime会针对矢量图以及文本自动做dpi自适应Q由于矢量图l制会生痕q,所以最好在设计时按照低dpiQ比?60QAdobe官方)来设计,在dpi=240的设备上Qruntime会自动将矢量图放Cؓ1.5倍?br />
对于位图来说Q放大会D痕迹Q因此flex sdk提供了MultiDPIBitmapSourcec,允许用户针对160,240,320分别提供位图。mobile app的splash不能采用MultiDPIBitmapSourceQ最好用大位图Q让runtime自动~小它?br />
在skin中,判断applicationDpiQ?br />
switch (applicationDPI) {
case DPIClassification.DPI_320: {
upBorderSkin = skins.assets320.TransparentRoundedButton_up;
downBorderSkin = skins.assets320.TransparentRoundedButton_down;
break;
}


在css中,采用@mediaQ?br />@media (application-dpi: 160) {
 Button { fontSize: 20; }
}

要提供良好体验的splashQ需要扩展SplashScreenc,重写getImageClassҎQ比如:
override mx_internal function getImageClass(dpi:Number, aspectRatio:String):Class {
if (dpi == DPIClassification.DPI_160)
return SplashImage160;
else if (dpi == DPIClassification.DPI_240)
return SplashImage240;
else if (dpi == DPIClassification.DPI_320)
return SplashImage320; return null;
}
}



不做躁的h 2014-02-06 19:26 发表评论
]]>
flex mobile性能优化?/title><link>http://m.tkk7.com/bjwulin/archive/2014/02/06/409550.html</link><dc:creator>不做躁的h</dc:creator><author>不做躁的h</author><pubDate>Thu, 06 Feb 2014 07:27:00 GMT</pubDate><guid>http://m.tkk7.com/bjwulin/archive/2014/02/06/409550.html</guid><wfw:comment>http://m.tkk7.com/bjwulin/comments/409550.html</wfw:comment><comments>http://m.tkk7.com/bjwulin/archive/2014/02/06/409550.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/bjwulin/comments/commentRss/409550.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/bjwulin/services/trackbacks/409550.html</trackback:ping><description><![CDATA[<div>q个mobile开发,一般原生开发也许是最合适的方式Q但是涉及到跨^台的问题Q有_֊的团队一般都会逐个ZUd操作pȝq行开发。但是我q求短小Q精悍,快速。于是我希望能够跨^収ͼZhtml5开发是一个不错的选择Q但是终I因为团队更熟悉flexQ于是决定采用flex mobile development来进入移动互联的开发?br /><br />flex是个双刃剑,我见q用的好的,做出来的效果不比原生差,也见q做的不好的Q那效果Q那性能真的不敢恭维Q我的团队一直在台式机的flex app开发上Q很关于客Lapp的性能优化Q于是写此日志作为备忘,大部分都是网l的׃n观点Q不q经q我验证后得以收UI<br /><br />1、组件尽量用ؓUd开发优化的Q皮肤尽量用简z的Q一般最好通过graphic以及fxg语法来绘Ӟ不要q多嵌入位图?br />2、itemRenderer最好用As3的,mobile theme里面有LabelItemRenderer以及IconItemRendererQ里面需要重载的Ҏ有createChildren,measure,drawBackground,layoutContent以及数据的setter。相比Flex ItemRendererQmobile的ItemRenderer的updateDisplayList分割成drawBackground和LayoutContent。IconItemRenderer使用flex ContentCache高速缓存下载下来的囑Ş囑փ?br />3、用styleableTextFieldQ该cd可以在As3中用,不能在mxml中用,性能在mobile中比Label和RichText性能高不?br />4、让flex ItemRender保持矩Ş形状q且讄OpaqueBackgroundZ个单一颜色?br />5、如果在flex ItemRenderer中绘制自q背景Q则需要将autoDrawBackground为false?br />6、flex ItemRenderer如果外观保持静态,可以讄cacheAsBitmap为true?br />7、flex ItemRenderer量用双向绑定?br />8、布局定位lgQ尽量用容器组件的layout属性来辑ֈ布局目的Q尽量少地嵌入容器组Ӟ减少容器lg层次{?br />9、优先考虑ConstraintLayout布局方式Q减动态布局?br />10、用Group和Graphics fxg来代替BorderContainer?br />11、flex mobile中不要用CreationComplete来初始化view的外观,直接覆盖data的setterҎQ尽量避免用双向绑定以及绑定表辑ּ?br />12、徏议在View的ViewActivate中调用远E异步服务以及处理子lg的初始化{工作,避免用户体验中的”停顿“?br />13、用IncludeIn或ExcludeFrom以state的方式隐藏或昄lg?br />14、如果一个View来回被用h切入Q那么最好指定该View的destructionPolicy为neverQ即在内存中一直保留该view的实例?br />15、用BitmapImage代替Imageq行囑փ嵌入工作?br />16、用RectangularDropShadow代替DropShadowFilter<br />17、用图像的多个寸备䆾Q而不是用大?~放或者图形圆滑技术来适应不同分L率和dpi?br />18、尽量用png囑ŞQ而不是采用jpg或者gif.<br />19、对于简单图形,可以采用graphics或者rect fill{,对于复杂一点的囑Ş采用Adobe Illustrator来绘制fxg矢量囑Ş?br />20、尽量用cssQ利用mobile theme已有的皮肤,因ؓq些皮肤已经高度优化?br />21、如果mobile theme的css样式不Q则需要用as3来编写皮肤或者扩展已有组件的皮肤?/div><img src ="http://m.tkk7.com/bjwulin/aggbug/409550.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/bjwulin/" target="_blank">不做躁的h</a> 2014-02-06 15:27 <a href="http://m.tkk7.com/bjwulin/archive/2014/02/06/409550.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu server下安装redishttp://m.tkk7.com/bjwulin/archive/2014/01/16/409029.html不做躁的h不做躁的hThu, 16 Jan 2014 07:04:00 GMThttp://m.tkk7.com/bjwulin/archive/2014/01/16/409029.htmlhttp://m.tkk7.com/bjwulin/comments/409029.htmlhttp://m.tkk7.com/bjwulin/archive/2014/01/16/409029.html#Feedback3http://m.tkk7.com/bjwulin/comments/commentRss/409029.htmlhttp://m.tkk7.com/bjwulin/services/trackbacks/409029.html
I白的ubuntu serverQ一步一步来?br />
1、首先在ubuntu server里面安装openssh serverQ通过tasksel命o调出taskQ选择openssh serverq行安装?br />2、我一般用windows办公Q直接用puttyQ通过ip和portq接服务器,注意一点的是connection的seconds between keepalives讄旉E微长一些,毕竟通信q程有gq?br />3、用wget下蝲redis的稳定版本,然后用tar解压Q进入到解压目录。执行makeQ提Cmake没有安装?br />4、用sudo apt-get install make和sudo apt-get install gcc安装两个~译器?br />5、在redis解压目录下,执行makeQ如果提C?#8220;error: jemalloc/jemalloc.h: No such file or directory”Q则可以先执行指令:make distclean
6、make完后Q一般徏议make testQ我在make test时提C?#8220;You need tcl 8.5 or newer in order to run the Redis test”
7、wget http://prdownloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz,下蝲后,q入安装目录Q进入unixQ然后执?./configure",然后makeQ然后make installQ告诉我没有权限建立文gQ在make前加上sudoQ?/span>
8、然后跑到redis的解压目录下Q再q行"make test"Q很多很多okQ哈哈?br />9、然后make installQ这样以后执行命令不用上全\?br />10、开发环境中启动Qredis-server --port 6000,命o行客LQredis-cli -h 192.168.1.10 -p 6000Q然后就可以用redis的各U命令交互了?br />
ȝQ我是老白Q不qubuntu serverZdebian,真心很好用,debian的更新周期太长,所以ubuntuq是不错的?br />
每次启动redisQL报告QUnable to set the max number of files limit
解决ҎQ?br />
1.打开/etc/security/limits.confQ里面有很详l的注释Q找到如下设|?如果没有插?
* soft nofile 51200
* hard nofile 51200
2.~辑/etc/pam.d/common-sessionQ加入一?br />session required pam_limits.so
3.~辑/etc/profileQ加?br />ulimit -SHn 51200
重启服务器,再次登陆Q查看句柄数Q已l正设|ؓ51200?/div>

不做躁的h 2014-01-16 15:04 发表评论
]]> վ֩ģ壺 þ99þóѲ| þþƷŮav鶹 | ѹۿ| ޾Ʒ˳߹ۿ| ްv2017| AVһ | ҹþþþƷӰԺ| anպר| ҳڻӭ| Ƶ| avŷǮ| ĻƷ| ޸޵ | ˳ɫ77777߹ۿ| VƬ߲| 91Ƶ| Ļѹۿ| ˳ɶ߲r18| AëƬA| aëƬѧѹۿ| ޻ɫ߹ۿվ| ֱ߹ۿƵƵ| ò| avרߵӰ| ձƵһ߹ۿ| ۺɫ| Ƶ| ŮɫŷŮ| 18վ| vavavaþ| Ļ| ˳վ߹ۿ | ޸Ļ| պ߸| Ļ߸ѵӰ| ձ˻ʿxxxxƵ| Ƶ| ȫѹɫһ| 97Ƶ| ޾ƷVAƬ߲| 18վƬѹۿ|