当前位置: 首页 > news >正文

做网站面临的困难融水县住房和城乡建设局网站

做网站面临的困难,融水县住房和城乡建设局网站,汉中市住房和城乡建设局网站,徐州营销型网站制使地图事件触发本文介绍如何通过使用映射触发器来处理一致性事件。 基本上#xff0c;建议使用Oracle Coherence中的分布式数据管理来研究Oracle Coherence API的基本配置和实现。 映射触发器是Oracle Coherence提供最高度定制的缓存管理系统的最重要功能之一。 MapTrigger表示… 地图事件触发 本文介绍如何通过使用映射触发器来处理一致性事件。 基本上建议使用Oracle Coherence中的分布式数据管理来研究Oracle Coherence API的基本配置和实现。 映射触发器是Oracle Coherence提供最高度定制的缓存管理系统的最重要功能之一。 MapTrigger表示一种功能代理它允许针对基础地图进行验证拒绝或修改变异操作。 此外它们还可以防止无效事务增强安全性提供事件日志记录和审核以及收集有关数据修改的统计信息。 例如我们有与NamedCache一起使用的代码并且我们想要在将条目插入地图之前更改条目的行为或内容。 通过启用映射触发器可以在不修改所有现有代码的情况下进行此更改。 有两种方法可以将“地图触发器”功能添加到应用程序 1一种MapTriggerListener可以使用具有指定的高速缓存来注册MapTrigger 2可以在coherence-cache-config.xml配置文件中使用类工厂机制 在以下示例应用程序中通过遵循第一种方法来实现MapTrigger功能。 创建了一个称为OTV的新集群并通过在该集群的两个成员之间使用的用户映射NamedCache对象分发了User bean。 二手技术 JDK 1.6.0_35 Spring3.1.2 连贯性3.7.1 Maven的3.0.2 步骤1建立已完成的专案 创建一个Maven项目如下所示。 可以使用Maven或IDE插件创建。 第2步相干套餐 通过Coherence软件包下载Coherence 步骤3图书馆 首先将Spring依赖项添加到Maven的pom.xml中。 !-- Spring 3.1.2 dependencies --dependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion${spring.version}/version/dependency Coherence库是手动安装到Local Maven Repository的其描述如下所示添加到pom.xml中。 另外如果不使用Maven管理项目则可以将coherence.jar文件添加到classpath中。 !-- Coherence library(from local repository) --dependencygroupIdcom.tangosol/groupIdartifactIdcoherence/artifactIdversion3.7.1/version/dependency 为了创建runnable-jar 可以使用以下Maven插件。 plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-shade-plugin/artifactIdversion1.3.1/versionexecutionsexecutionphasepackage/phasegoalsgoalshade/goal/goalsconfigurationtransformerstransformerimplementationorg.apache.maven.plugins.shade.resource.ManifestResourceTransformermainClasscom.otv.exe.Application/mainClass/transformertransformerimplementationorg.apache.maven.plugins.shade.resource.AppendingTransformerresourceMETA-INF/spring.handlers/resource/transformertransformerimplementationorg.apache.maven.plugins.shade.resource.AppendingTransformerresourceMETA-INF/spring.schemas/resource/transformer/transformers/configuration/execution/executions/plugin 步骤4建立otv-coherence-cache-config.xml 第一个Coherence配置文件是otv-coherence-cache-config.xml 。 它包含分布式或复制的缓存方案和缓存方案映射配置。 创建的缓存配置应添加到coherence-cache-config.xml中 。 ?xml version1.0?cache-config xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlnshttp://xmlns.oracle.com/coherence/coherence-cache-configxsi:schemaLocationhttp://xmlns.oracle.com/coherence/coherence-cache-configcoherence-cache-config.xsdcaching-scheme-mappingcache-mappingcache-nameuser-map/cache-namescheme-nameMapDistCache/scheme-name/cache-mapping/caching-scheme-mappingcaching-schemesdistributed-schemescheme-nameMapDistCache/scheme-nameservice-nameMapDistCache/service-namebacking-map-schemelocal-schemeunit-calculatorBINARY/unit-calculator/local-scheme/backing-map-schemeautostarttrue/autostart/distributed-scheme/caching-schemes/cache-config 步骤5创建tangosol-coherence-override.xml 第二个Coherence配置文件是tangosol-coherence-override.xml 。 它包含集群成员身份和可配置缓存工厂配置。 集群的第一个成员的tangosol-coherence-override.xml ?xml version1.0?coherence xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlnshttp://xmlns.oracle.com/coherence/coherence-operational-configxsi:schemaLocationhttp://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsdcluster-configmember-identitycluster-nameOTV/cluster-namerole-nameOTV1/role-name/member-identityunicast-listenerwell-known-addressessocket-address id1addressx.x.x.x/addressport8089/port/socket-addresssocket-address id2addressx.x.x.x/addressport8090/port/socket-address/well-known-addressesmachine-id1001/machine-idaddressx.x.x.x/addressport8089/portport-auto-adjusttrue/port-auto-adjust/unicast-listener/cluster-configconfigurable-cache-factory-configinit-paramsinit-paramparam-typejava.lang.String/param-typeparam-value system-propertytangosol.coherence.cacheconfigotv-coherence-cache-config.xml/param-value/init-param/init-params/configurable-cache-factory-config/coherence 集群的第二个成员的tangosol-coherence-override.xml ?xml version1.0?coherence xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlnshttp://xmlns.oracle.com/coherence/coherence-operational-configxsi:schemaLocationhttp://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsdcluster-configmember-identitycluster-nameOTV/cluster-namerole-nameOTV2/role-name/member-identityunicast-listener well-known-addressessocket-address id1addressx.x.x.x/addressport8090/port/socket-addresssocket-address id2addressx.x.x.x/addressport8089/port/socket-address/well-known-addressesmachine-id1002/machine-idaddressx.x.x.x/addressport8090/portport-auto-adjusttrue/port-auto-adjust/unicast-listener/cluster-configconfigurable-cache-factory-configinit-paramsinit-paramparam-typejava.lang.String/param-typeparam-value system-propertytangosol.coherence.cacheconfigotv-coherence-cache-config.xml/param-value/init-param/init-params/configurable-cache-factory-config/coherence 步骤6创建applicationContext.xml Spring配置文件applicationContext.xml已创建。 beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd!-- Beans Declaration --bean iduserCacheService classcom.otv.srv.UserCacheService/beanbean iduserCacheUpdater classcom.otv.exe.UserCacheUpdaterproperty nameuserCacheService refuserCacheService //bean/beans 步骤7创建用户分类 创建了一个新的User Spring bean。 该bean将分布在OTV集群中的两个节点之间。 对于序列化已经实现了java.io.Serializable接口但是可以实现PortableObject以获得更好的性能。 package com.otv.user;import java.io.Serializable;/*** User Bean** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public class User implements Serializable {private static final long serialVersionUID -1963764656789800896L;private String id;private String name;private String surname; public String getId() {return id;}public void setId(String id) {this.id id;}public String getName() {return name;}public void setName(String name) {this.name name;}public String getSurname() {return surname;}public void setSurname(String surname) {this.surname surname;}Overridepublic String toString() {StringBuilder strBuff new StringBuilder();strBuff.append(id : ).append(id);strBuff.append(, name : ).append(name);strBuff.append(, surname : ).append(surname);return strBuff.toString();} } 步骤8建立IUserCacheService接口 为服务层创建了一个新的IUserCacheService接口以公开缓存功能。 package com.otv.srv;import com.tangosol.net.NamedCache;/*** IUserCacheService Interface exposes User Cache operations** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public interface IUserCacheService {/*** Adds user entries to cache** param Object key* param Object value**/void addToUserCache(Object key, Object value);/*** Deletes user entries from cache** param Object key**/void deleteFromUserCache(Object key);/*** Gets user cache** retun NamedCache Coherence named cache*/NamedCache getUserCache();} 步骤9创建UserCacheService IMPL类 通过实现IUserCacheService创建UserCacheService 。 package com.otv.srv;import com.otv.listener.UserMapListener; import com.otv.trigger.UserMapTrigger; import com.tangosol.net.CacheFactory; import com.tangosol.net.NamedCache; import com.tangosol.util.MapTriggerListener;/*** CacheService Class implements the ICacheService** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public class UserCacheService implements IUserCacheService {private NamedCache userCache null;private static final String USER_MAP user-map;private static final long LOCK_TIMEOUT -1;public UserCacheService() {setUserCache(CacheFactory.getCache(USER_MAP));getUserCache().addMapListener(new UserMapListener());getUserCache().addMapListener(new MapTriggerListener(new UserMapTrigger()));} /*** Adds user entries to cache** param Object key* param Object value**/public void addToUserCache(Object key, Object value) {// key is lockedgetUserCache().lock(key, LOCK_TIMEOUT);try {// application logicgetUserCache().put(key, value);} finally {// key is unlockedgetUserCache().unlock(key);}}/*** Deletes user entries from cache** param Object key**/public void deleteFromUserCache(Object key) {// key is lockedgetUserCache().lock(key, LOCK_TIMEOUT);try {// application logicgetUserCache().remove(key);} finally {// key is unlockedgetUserCache().unlock(key);}}/*** Gets user cache** retun NamedCache Coherence named cache*/public NamedCache getUserCache() {return userCache;}public void setUserCache(NamedCache userCache) {this.userCache userCache;}} 步骤10创建UserMapTrigger类 通过实现com.tangosol.util.MapTrigger接口可以创建一个新的UserMapTrigger类。 在将条目插入到用户映射中之前此触发器将处理逻辑。 package com.otv.trigger;import org.apache.log4j.Logger;import com.otv.listener.UserMapListener; import com.otv.user.User; import com.tangosol.util.MapTrigger;/*** UserMapTrigger executes required logic before the operation is committed** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public class UserMapTrigger implements MapTrigger {private static final long serialVersionUID 5411263646665358790L;private static Logger logger Logger.getLogger(UserMapListener.class);/*** Processes user cache entries** param MapTrigger.Entry entry**/public void process(MapTrigger.Entry entry) {User user (User) entry.getValue();String id user.getId();String name user.getName();String updatedName name.toUpperCase();String surname user.getSurname();String updatedSurname surname.toUpperCase();if (!updatedName.equals(name)) {user.setName(updatedName);}if (!updatedSurname.equals(surname)) {user.setSurname(updatedSurname);}user.setId(user.getName() _ user.getSurname());entry.setValue(user);logger.debug(UserMapTrigger processes the entry before committing. oldId : id , newId : ((User)entry.getValue()).getId() , oldName : name , newName : ((User)entry.getValue()).getName() , oldSurname : surname , newSurname : ((User)entry.getValue()).getSurname());}public boolean equals(Object o) {return o ! null o.getClass() this.getClass();}public int hashCode() {return getClass().getName().hashCode();} } 步骤11建立USERMAPLISTENER IMPL类别 创建一个新的UserMapListener类。 该侦听器接收分布式的用户映射事件。 package com.otv.listener;import org.apache.log4j.Logger;import com.tangosol.util.MapEvent; import com.tangosol.util.MapListener;/*** UserMapListener Class listens user cache events** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public class UserMapListener implements MapListener {private static Logger logger Logger.getLogger(UserMapListener.class);public void entryDeleted(MapEvent me) {logger.debug(Deleted Key me.getKey() , Value me.getOldValue());}public void entryInserted(MapEvent me) {logger.debug(Inserted Key me.getKey() , Value me.getNewValue());}public void entryUpdated(MapEvent me) { // logger.debug(Updated Key me.getKey() , New_Value me.getNewValue() , Old Value me.getOldValue());} } 步骤12创建CacheUpdater类 创建CacheUpdater类以添加新条目以缓存和监视缓存内容。 package com.otv.exe;import java.util.Collection;import org.apache.log4j.Logger;import com.otv.srv.IUserCacheService; import com.otv.user.User;/*** CacheUpdater Class updates and prints user cache entries** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public class UserCacheUpdater implements Runnable {private static Logger logger Logger.getLogger(UserCacheUpdater.class);private IUserCacheService userCacheService;/*** Runs the UserCacheUpdater Thread**/public void run() { //New User are created...User user new User();//Only Name and Surname properties are set and Id property will be set at trigger level.user.setName(James);user.setSurname(Joyce);//Entries are added to cache...getUserCacheService().addToUserCache(user1, user);// The following code block shows the entry which will be inserted via second member of the cluster // so it should be opened and above code block should be commented-out before the project is built.// user.setName(Thomas); // user.setSurname(Moore); // getUserCacheService().addToUserCache(user2, user);//Cache Entries are being printed...printCacheEntries();}/*** Prints User Cache Entries**/SuppressWarnings(unchecked)private void printCacheEntries() {CollectionUser userCollection null;try {while(true) {userCollection (CollectionUser)getUserCacheService().getUserCache().values();for(User user : userCollection) {logger.debug(Cache Content : user);}Thread.sleep(60000);}} catch (InterruptedException e) {logger.error(CacheUpdater is interrupted!, e);}}public IUserCacheService getUserCacheService() {return userCacheService;}public void setUserCacheService(IUserCacheService userCacheService) {this.userCacheService userCacheService;} } 步骤13创建应用程序类 创建应用程序类以运行应用程序。 package com.otv.exe;import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;/*** Application class starts the application** author onlinetechvision.com* since 29 Oct 2012* version 1.0.0**/ public class Application {/*** Starts the application** param String[] args**/public static void main(String[] args) {ApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);UserCacheUpdater cacheUpdater (UserCacheUpdater) context.getBean(userCacheUpdater);new Thread(cacheUpdater).start();} } nbsp; 步骤14建立专案 在构建OTV_Spring_Coherence_MapTrigger项目之后将创建OTV_Spring_Coherence_MapTrigger-0.0.1-SNAPSHOT.jar 。 重要说明群集的成员具有不同的Coherence配置因此应为每个成员分别构建项目。 步骤15通过启动集群成员来运行项目 在集群成员上运行了OTV_Spring_Coherence-0.0.1-SNAPSHOT.jar文件后以下输出日志将显示在第一个成员的控制台上 --A new cluster is created and First Member joins the cluster and adds a new entry to the cache. 29.10.2012 18:26:44 DEBUG (UserMapTrigger.java:49) - UserMapTrigger processes the entry before committing. oldId : null, newId : JAMES_JOYCE , oldName : James, newName : JAMES, oldSurname : Joyce, newSurname : JOYCE 29.10.2012 18:26:44 DEBUG (UserMapListener.java:25) - Inserted Key user1, Value id : JAMES_JOYCE, name : JAMES, surname : JOYCE 29.10.2012 18:26:44 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : JAMES_JOYCE, name : JAMES, surname : JOYCE.......--Second Member joins the cluster and adds a new entry to the cache. 29.10.2012 18:27:33 DEBUG (UserMapTrigger.java:49) - UserMapTrigger processes the entry before committing. oldId : null, newId : THOMAS_MOORE, oldName : Thomas, newName : THOMAS, oldSurname : Moore, newSurname : MOORE 29.10.2012 18:27:34 DEBUG (UserMapListener.java:25) - Inserted Key user2, Value id : THOMAS_MOORE, name : THOMAS, surname : MOORE.......--After second member adds a new entry, cache content is shown as below : 29.10.2012 18:27:44 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : THOMAS_MOORE, name : THOMAS, surname : MOORE 29.10.2012 18:27:45 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : JAMES_JOYCE, name : JAMES, surname : JOYCE 29.10.2012 18:28:45 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : THOMAS_MOORE, name : THOMAS, surname : MOORE 29.10.2012 18:28:45 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : JAMES_JOYCE, name : JAMES, surname : JOYCE 第二成员的控制台 --After Second Member joins the cluster and adds a new entry to the cache, cache content is shown as below and the members has got same entries :. 29.10.2012 18:27:34 DEBUG (UserMapListener.java:25) - Inserted Key user2, Value id : THOMAS_MOORE, name : THOMAS, surname : MOORE 29.10.2012 18:27:34 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : JAMES_JOYCE, name : JAMES, surname : JOYCE 29.10.2012 18:27:34 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : THOMAS_MOORE, name : THOMAS, surname : MOORE 29.10.2012 18:28:34 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : JAMES_JOYCE, name : JAMES, surname : JOYCE 29.10.2012 18:28:34 DEBUG (UserCacheUpdater.java:63) - Cache Content : id : THOMAS_MOORE, name : THOMAS, surname : MOORE 步骤16下载 https://github.com/erenavsarogullari/OTV_Spring_Coherence_MapTrigger 参考 Online Technology Vision博客上的JCG合作伙伴 Eren Avsarogullari 使用地图触发功能进行的一致性事件处理 。 翻译自: https://www.javacodegeeks.com/2012/11/coherence-event-processing-by-using-map-trigger-feature.html地图事件触发
http://www.zqtcl.cn/news/633086/

相关文章:

  • 做翻糖的网站深圳做购物网站
  • 国外界面设计网站海淘网站
  • 全国住房城乡建设厅网站wordpress 宽版
  • 网站建设实训意见中国建设人才信息网站
  • 如何给网站做301跳转中国做机床的公司网站
  • 网站建设课程体系济南建站详情
  • jsp网站空间网站开发北京 广告 手机网站
  • 郑州网站建设推广爱站网seo综合查询工具
  • 2017年网站开发用什么语言手游排行榜
  • 鞍山百度网站怎么制作建设部网站建造师公示
  • 建设部网站业绩补录营销型网站制作的方法
  • 建设网站的功能及目的是什么意思兰州网络优化seo
  • 用ps软件做ppt模板下载网站有哪些内容广州seo服务外包
  • 毕业设计论文网站开发需要多少湛江建站免费模板
  • 做豆制品的网站集团网站建设策划方案
  • 燕郊网站制作哈尔滨企业网站建站推荐
  • 本地网站做通用会员卡建立电子商务网站目的
  • ftp网站地图怎么做网站模板出售
  • 用rp怎么做网站导航菜单手机app制作入门教程
  • 国外创意网站市场营销在线课程
  • 怎么做点图片链接网站网站建设云解析dns有什么用
  • 重庆网站建设哪家公司哪家好企业 网站规划与网页设计word
  • 手机必备软件100个网站建设和优化排名
  • 天津公司网站怎样制作网页设计图片尺寸
  • 网站建设中模板代码网络营销推广公司哪家好
  • 百度免费建立网站搜索引擎推广效果
  • 网站建设分金手指排名十二建设内容管理网站的目的
  • 无锡网站策划制作网站的工具
  • 免费的网站开发软件百度做网站推广的费用
  • 汽车维修东莞网站建设怎么用阿里的域名 做网站