<< 十二月 2012 | 首页 | 二月 2013 >>

iPhone5和iOS6上HTML5开发的新增功能

开发移动应用到底是选择native、Web应用或者混合应用?答案是不同的移动应用需要不同的技术,选择合适的就行。其实大多数移动应用,不管是企业移动应用还是互联网移动应用,90%都可以使用基于HTML5的Web技术就足够。在Android 4.0和iOS 6以上浏览器已经是最快的应用了,比任何本地的微博、微信都快,无须更新升级,无须上传分裂的APP市场,无须突然被苹果下架应用。再看看最近发布 Firefox OS 开发手机的配置也大概知道,运行大多数应用不需要那么高配置。

目前主流的智能终端中,iOS6对HTML5的支持程度仍旧是最好的,领先于Android和Windows phone。随着iPhone5的性能再次翻倍,以及iOS不断提升的canvas渲染性能,加之Android的webGL,Win8/wp8的本地api对Javascript开放,性能已经不再是开发优秀移动应用的主要屏障,如今要考虑的是如何发挥HTML5的优势做出用户喜欢的应用。下面看看iPhone5和iOS6上HTML5开发的新增功能

 

阅读全文……

标签 : ,

Java 开发 2.0: 使用 Hibernate Shards 进行切分

当关系数据库试图在一个单一表中存储数 TB 的数据时,总性能经常会降低。显然,对所有数据编索引不仅对于读而且对于写都很耗时。因为 NoSQL 数据商店尤其适合存储大型数据(如 Google 的 Bigtable),显然 NoSQL 是一种非关系数据库方法。对于倾向于使用 ACID-ity 和实体结构关系数据库的开发人员及需要这种结构的项目来说,切分是一个令人振奋的可选方法。

切分 是数据库分区的一个分支,但是它不是本地数据库技术 — 切分发生在应用程序级别。在各种切分实现中,Hibernate Shards 是 Java™ 技术世界中最受欢迎的一个。这个灵活绝妙的项目可以让您使用映射至逻辑数据库的 POJO 对切分数据集进行几乎无缝操作(我将在下文简要介绍 “几乎” 的原因)。使用 Hibernate Shards 时,您无须将您的 POJO 特别映射至切分 — 您可以像使用 Hibernate 方法对任何常见关系数据库进行映射时一样对其进行映射。Hibernate Shards 可以为您管理低级别的切分任务。

到目前为止,在本 系列 中,我已经使用了一个基于比赛和参赛者类推关系的简单域展示了各种数据库存储技术。本月,我将继续使用这个熟悉的示例介绍一种实用的切分技术,然后在 Hibernate Shards 中对其进行实现。注意:与切分相关的主要工作与 Hibernate 没有太大关系;事实上,Hibernate Shards 的编码工作比较简单。其中关键的部分在于判断 如何进行切分以及对什么进行切分。

阅读全文……

标签 :

Hibernate Shards 数据的水平、垂直切割(二)- Hibernate Shards基本演示 - riccc - 博客园

1. 通过id加载实体的时候,hibernate shards使用ShardSelectionStrategy来决定应当从哪个shard加载数据
2. 新增数据的时候,hibernate shards使用ShardResolutionStrategy来决定应当将数据insert到哪个shard中
    这里为什么不能使用ShardSelectionStrategy呢?因为与id的生成机制相关,比如说可以让数据库来生成id(hibernate中的native方式),例如自增id,在shard的应用场景下可以简单的给每个shard一个起止范围,只是在insert数据的时候必须通过特定的算法决定将数据insert到哪个shard中,这样的情况下ShardSelectionStrategy是无法运用的。而对于assigned等类似的id生成机制,还是可以运用ShardSelectionStrategy策略的
3. 执行hql或者Criteria查询的时候,则使用ShardAccessStrategy从shard中查询数据
    上面示例中的buildShardStrategyFactory方法中,我们使用了hibernate shards项目提供的SequentialShardAccessStrategy策略,这个策略在所有shards中逐个执行查询语句,然后对各个结果进行合并 

阅读全文……

标签 :

数据挖掘和机器学习的区别_失败只有一种,就是半途而废!——追梦(huzhyi)_百度空间

      数据挖掘和机器学习的区别和联系,周志华有一篇很好的论述《机器学习与数据挖掘》可以帮助大家理解。数据挖掘受到很多学科领域的影响,其中数据库、机器学习、统计学无疑影响最大。简言之,对数据挖掘而言,数据库提供数据管理技术,机器学习和统计学提供数据分析技术。由于统计学往往醉心于理论的优美而忽视实际的效用,因此,统计学界提供的很多技术通常都要在机器学习界进一步研究,变成有效的机器学习算法之后才能再进入数据挖掘领域。从这个意义上说,统计学主要是通过机器学习来对数据挖掘发挥影响,而机器学习和数据库则是数据挖掘的两大支撑技术。从数据分析的角度来看,绝大多数数据挖掘技术都来自机器学习领域,但机器学习研究往往并不把海量数据作为处理对象,因此,数据挖掘要对算法进行改造,使得算法性能和空间占用达到实用的地步。同时,数据挖掘还有自身独特的内容,即关联分析。

而模式识别和机器学习的关系是什么呢,传统的模式识别的方法一般分为两种:统计方法和句法方法。句法分析一般是不可学习的,而统计分析则是发展了不少机器学习的方法。也就是说,机器学习同样是给模式识别提供了数据分析技术。

 

 

数据挖掘是从巨量数据中获取有效的、新颖的、潜在有用的、最终可理解的模式的非平凡过程. 通俗地说,现在人们已经被海量数据所淹没了,而数据挖掘则是希望帮助人们从数据中发现有用的知识. 数据挖掘中用到了大量的机器学习界提供的数据分析技术和数据库界提供的数据管理技术. 从数据分析的角度来看,数据挖掘与机器学习有很多相似之处,但不同之处也是显著的,例如:数据挖掘并没有机器学习探索人的学习机制这一科学发现任务;数据挖掘中的数据分析是针对巨量数据进行的. 从某种意义上说,机器学习的科学成分更重一些,而数据挖掘的技术成分更重一些. 目前,数据挖掘已经在欧美等发达国家得到了很多应用(由于中国的信息电子化起步较晚,数据挖掘的应用还不太多),但这个领域中需要深入研究的问题仍然非常多. 数据挖掘也是 LAMDA 的核心研究领域.

 

 

 

学习能力是智能行为的一个非常重要的特征,不具有学习能力的系统很难称为一个真正的智能系统, 而机器学习则是希望使(计算机)系统能够利用经验来改善自身的性能,因此该领域一直是人工智能的核心研究领域之一。在计算机系统中,"经验"通常是以数据的形式存在的,因此机器学习不仅涉及到对人的认知学习过程的探索,还涉及到对数据的分析处理 。实际上,机器学习已经成为计算机数据分析技术的创新源头之一。由于几 乎所有的学科都要面对数据分析任务,因此机器学习已经开始影响到计算机科学的众多领域,甚至计算机科学之外的很多学科。从火星探测机器人、基因芯片到汽车自动驾驶、智能家电,机器学习都在背后发挥着重要的作用,但这个领域中需要深入研究的问题仍然非常多. 机器学习是 LAMDA 的核心研究领域。---源自LAMDA主页

 

 

数据挖掘与机器学习经典图书介绍:http://www.cc-edu.net/lanmu/JCJS/2008_09.pdf

       对于“数据挖掘”,有多种文字不同但含义接近的定义,简单来说,可以归纳为“试图从海量数据中找出有用的知识”。在学术界,有时也将“数据挖掘(DM)”称为“数据库中的知识发现(KDD)”。而“机器学习”是人工智能的核心研究领域之一,目前被广泛采用的机器学习的定义是“利用经验来改善
计算机系统自身的性能
”。
      南京大学的周志华教授曾专门撰文论述了数据挖掘和机器学习以及数据库之间的关系,他提出:数据挖掘可以视为机器学习和数据库的交叉,主要利用机器学习界提供的技术来分析海量数据,利用数据库界提供的技术来管理海量数据。
      组成数据挖掘的三大支柱包括统计学、机器学习和数据库领域内的研究成果,其他还包含了可视化、信息科学等内容。不同的教材从不同的方面结合其基础学科知识讲述数据挖掘技术,不同专业和技术背景的学生或数据挖掘研究人员和应用人员可以根据自身的专业方向选择不同的数据挖掘切入点。

另附周志华 《数据挖掘与机器学习》http://xinxi.xaufe.edu.cn/kejian/files/05033at2007121222135317664.pdf

 

阅读全文……

标签 : ,

iPhone5和IOS6对HTML5的新增支持_博看文思-HTML5_百度空间

尽管桌面平台上的safari一直不是最好的HTML5浏览器,但随着iPhone5和IOS6的正式发布,苹果再一次增加了很多HTML5的特性支持。不难看出苹果仍是HTML5发展的中流砥柱。

  1. iPhone5改变了iPhone一直以来的2:3屏幕宽高比,变为了40:71。之前做iPhone上的应用和游戏,大部分只需要考虑320*480即可,而之后我们必须再考虑:320*568

  2. 支持文件上传的标签。终于可以在浏览器内上传文件了。

  3. 可以访问摄像头。通过HTML5的Media Capture API 即可。

  4. web Audio API的原生支持。IOS对HTML5 音频的支持可谓是臭名昭著,如今开发者们终于等来了音频的支持。在此之前,音视频的实现都是通过IOS的QuickTime插件实现的,在做游戏开发的时候并不能很好的使用,最明显的就是多音频同时播放的问题。

  5. CSS3 滤镜。和IE系列的滤镜类似(滤镜无非也就那几种),不过性能和稳定性要比IE滤镜强太多,连微软都已经抛弃自家开发的滤镜,转投标准下的CSS3 滤镜。

  6. CSS3 cross fade。新增了一些 CSS Image Values支持。设计师们又有新的东西可以玩了

  7. 全屏支持。离全屏API的开放也不远了。

     

  8. requestAnimationFrame的支持。这个由Firefox程序员提出来的概念,如今得到快速的发展和应用。在做动画的时候,由于它减少了dom的回流重回,以及和屏幕刷新频率同步,它能带来比setTimeout/setInterval更好的性能,以及更少的CPU消耗。

  9. 离线缓存的大小限制增加到了25M。

  10. meta标签可以为web app定义不同的名字了。这个名字会显示在IOS的桌面上。<meta name="apple-mobile-web-app-title" content="My App Name">

  11. 指定 apple-mobile-web-app-capable 的web app将拥有独自的沙盒。这意味着及时来自同一个域下的web app,都拥有自己的沙盒文件系统,不会彼此干扰。这里面的内容会永久存储起来。之前IOS会在资源不够用的时候,影响到这些数据

  12. 原生支持了Web Inspector远程调试。这是由webkit 调试API开发出来的一个工具,用以实现远程调试。早在IOS5中就已经有私有API可以实现远程调试了,目前也可以在xcode中直接调试iphone中的HTML5页面。Web Inspector绝对是HTML5移动终端开发的一件利器,常用的一个工具是iwebinspector

  13. app安装提示框。首先找到一款itunes中的app,然后在页面中加上相应的meta:<meta name="apple-itunes-app" content="app-id=9999999"> 即可实现用户在进入该页面后,系统自动提示他安装该应用。

  14. canvas实现了两个私有api:webkitGetImageDataHD 和webkitSetImageDataHD.

  15. XMLHttpRequest Level 2的实现,可以监听数据加载进度,更方便的跨域都是Level2的亮点

  16. CSS3 Exclusions和 CSS3 Regions在IOS6 beta1中已经实现,但是正式版中却又移除了。CSS3 Regions是一种新的复杂布局,可以实现类似杂志的复杂无规律的布局,是由Adobe公司提交给W3C的一项技术。

  17. -webkit-transform:perserve-3d不会强制GPU加速。

 

目前在主流的智能终端中,IOS6对HTML5的支持程度仍旧是最好的,远远领先于android和windows phone。随着iPhone5的性能再次翻倍,以及IOS不断提升的canvas渲染性能,加之android的webgl,win8/wp8的本地api对Javascript开放,性能已经不再是开发大型HTML5游戏的主要屏障,如今要考虑的是如何发挥HTML5的优势做出用户喜欢游戏。

阅读全文……

标签 : , ,

using my own FORM_LOGIN_FILTER

<http auto-config="false" entry-point-ref="loginUrlAuthenticationEntryPoint">
		<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthenticationFilter" />

</http>

	<beans:bean id="myAuthenticationFilter" class="MyAuthenticationFilter">
		<beans:property name="authenticationManager" ref="authenticationManager"/>
		<beans:property name="authenticationFailureHandler" ref="failureHandler"/>
 		<beans:property name="authenticationSuccessHandler" ref="successHandler"/>
	</beans:bean>

	<beans:bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
 		<beans:property name="defaultTargetUrl" value="/login.spring"/>
	</beans:bean>

	<beans:bean id="failureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
 		<beans:property name="defaultFailureUrl" value="/login.spring?login_error=1"/>
	</beans:bean>

	<beans:bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
 		<beans:property name="loginFormUrl" value="/login.spring"/>
	</beans:bean>

阅读全文……

Creating a custom authentication with Acegi/Spring Security - Stack Overflow

  1. Implement a custom AuthenticationProvider which gets all your authentication information from the AuthenticationgetCredentials()getDetails(), and getPrincipal().

    Tie it into your Spring Security authentication mechanism using the following configuration snippet:

    <bean id="myAuthenticationProvider" class="com.example.MyAuthenticationProvider">   <security:custom-authentication-provider /> </bean> 
  2. This step is optional, if you can find a suitable one from standard implementations. If not, implement a class extending the Authentication interface on which you can put your authentication parameters:

    (e.g. a user identifier, timestamp, signature, etc.) 
  3. Extend a custom SpringSecurityFilter which ties the above two classes together. For example, the Filter might get the AuthenticationManager and call authenticate() using your implementation of Authentication as input.

    You can extend AbstractAuthenticationProcessingFilter as a start.

    You can reference UsernamePasswordAuthenticationFilter which extendsAbstractAuthenticationProcessingFilterUsernamePasswordAuthenticationFilterimplements the standard Username/Password Authentication.

  4. Configure your Spring Security to add or replace the standardAUTHENTICATION_PROCESSING_FILTER. For Spring Security Filter orders, seehttp://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html#filter-stack

    Here is a configuration snippet for how to replace it with your implementation:

    <beans:bean id="myFilter" class="com.example.MyAuthenticationFilter">   <custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/> </beans:bean>

阅读全文……

标签 :

Spring Security and CAS Interaction Sequence

Spring Security and CAS Interaction Sequence

The basic interaction between a web browser, CAS server and a Spring Security-secured service is as follows:

  1. The web user is browsing the service's public pages. CAS or Spring Security is not involved.

  2. The user eventually requests a page that is either secure or one of the beans it uses is secure. Spring Security's ExceptionTranslationFilter will detect the AccessDeniedException or AuthenticationException.

  3. Because the user's Authentication object (or lack thereof) caused an AuthenticationException, the ExceptionTranslationFilter will call the configuredAuthenticationEntryPoint. If using CAS, this will be the CasAuthenticationEntryPoint class.

  4. The CasAuthenticationEntryPoint will redirect the user's browser to the CAS server. It will also indicate a service parameter, which is the callback URL for the Spring Security service (your application). For example, the URL to which the browser is redirected might be https://my.company.com/cas/login?service=https%3A%2F%2Fserver3.company.com%2Fwebapp%2Fj_spring_cas_security_check.

  5. After the user's browser redirects to CAS, they will be prompted for their username and password. If the user presents a session cookie which indicates they've previously logged on, they will not be prompted to login again (there is an exception to this procedure, which we'll cover later). CAS will use thePasswordHandler (or AuthenticationHandler if using CAS 3.0) discussed above to decide whether the username and password is valid.

  6. Upon successful login, CAS will redirect the user's browser back to the original service. It will also include a ticket parameter, which is an opaque string representing the "service ticket". Continuing our earlier example, the URL the browser is redirected to might behttps://server3.company.com/webapp/j_spring_cas_security_check?ticket=ST-0-ER94xMJmn6pha35CQRoZ.

  7. Back in the service web application, the CasAuthenticationFilter is always listening for requests to /j_spring_cas_security_check (this is configurable, but we'll use the defaults in this introduction). The processing filter will construct a UsernamePasswordAuthenticationToken representing the service ticket. The principal will be equal to CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, whilst the credentials will be the service ticket opaque value. This authentication request will then be handed to the configured AuthenticationManager.

  8. The AuthenticationManager implementation will be the ProviderManager, which is in turn configured with the CasAuthenticationProvider. TheCasAuthenticationProvider only responds to UsernamePasswordAuthenticationTokens containing the CAS-specific principal (such asCasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER) and CasAuthenticationTokens (discussed later).

  9. CasAuthenticationProvider will validate the service ticket using a TicketValidator implementation. This will typically be a Cas20ServiceTicketValidatorwhich is one of the classes included in the CAS client library. In the event the application needs to validate proxy tickets, the Cas20ProxyTicketValidator is used. The TicketValidator makes an HTTPS request to the CAS server in order to validate the service ticket. It may also include a proxy callback URL, which is included in this example: https://my.company.com/cas/proxyValidate?service=https%3A%2F%2Fserver3.company.com%2Fwebapp%2Fj_spring_cas_security_check&ticket=ST-0-ER94xMJmn6pha35CQRoZ&pgtUrl=https://server3.company.com/webapp/j_spring_cas_security_proxyreceptor.

  10. Back on the CAS server, the validation request will be received. If the presented service ticket matches the service URL the ticket was issued to, CAS will provide an affirmative response in XML indicating the username. If any proxy was involved in the authentication (discussed below), the list of proxies is also included in the XML response.

  11. [OPTIONAL] If the request to the CAS validation service included the proxy callback URL (in the pgtUrl parameter), CAS will include a pgtIou string in the XML response. This pgtIou represents a proxy-granting ticket IOU. The CAS server will then create its own HTTPS connection back to the pgtUrl. This is to mutually authenticate the CAS server and the claimed service URL. The HTTPS connection will be used to send a proxy granting ticket to the original web application. For example, https://server3.company.com/webapp/j_spring_cas_security_proxyreceptor?pgtIou=PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt&pgtId=PGT-1-si9YkkHLrtACBo64rmsi3v2nf7cpCResXg5MpESZFArbaZiOKH.

  12. The Cas20TicketValidator will parse the XML received from the CAS server. It will return to the CasAuthenticationProvider a TicketResponse, which includes the username (mandatory), proxy list (if any were involved), and proxy-granting ticket IOU (if the proxy callback was requested).

  13. Next CasAuthenticationProvider will call a configured CasProxyDecider. The CasProxyDecider indicates whether the proxy list in the TicketResponse is acceptable to the service. Several implementations are provided with Spring Security: RejectProxyTicketsAcceptAnyCasProxy and NamedCasProxyDecider. These names are largely self-explanatory, except NamedCasProxyDecider which allows a List of trusted proxies to be provided.

  14. CasAuthenticationProvider will next request a AuthenticationUserDetailsService to load the GrantedAuthority objects that apply to the user contained in theAssertion.

  15. If there were no problems, CasAuthenticationProvider constructs a CasAuthenticationToken including the details contained in the TicketResponse and theGrantedAuthoritys.

  16. Control then returns to CasAuthenticationFilter, which places the created CasAuthenticationToken in the security context.

  17. The user's browser is redirected to the original page that caused the AuthenticationException (or a custom destination depending on the configuration).

It's good that you're still here! Let's now look at how this is configured

阅读全文……