目前我正在开发一个使用Spring 3.1和Hibernate 4的Web应用程序.
根据要求,我想在JSP页面上实现像Facebook这样的推送通知.如果您有任何建议,请同时列出兼容的浏览器及其版本.
Java是否支持任何队列对象或机制来处理批处理?
ex:我们有一个队列(或任何所需的队列对象),一些生产者将项目逐个推入队列,我的目标是当我们在这个队列中有10个项目或超过10个项目时,我们可以触发一些处理程序来处理它一批.
或者它不是自动触发的,我们需要找到一种在处理程序端优雅地循环队列的方法.
我们是否有典型的高性能对象或lib来处理这个问题?
谢谢,埃姆雷
鉴于代码
private static class MyHandler extends Handler
{
private final WeakReference<MainActivity> mTarget;
MyHandler(MainActivity intarget) {
mTarget = new WeakReference<MainActivity>(intarget);
}
@Override
public void handleMessage(Message msg)
{
MainActivity target = mTarget.get(); // target becomes null will causes null pointer exception
switch (msg.what) {
..
}
}
}
Run Code Online (Sandbox Code Playgroud)
为了避免NullPoinetrException,我可以使用:
if(target != null {
// do something
}
Run Code Online (Sandbox Code Playgroud)
但是当目标变为空时,我无法在应用程序中继续进行.
问题:
当它变为空并进一步继续或者我应该完成活动或应用程序时,有没有办法找回目标?
谢谢.
我在我的Web应用程序中使用Spring3.1和hibernate4.在这里,我正在尝试eh缓存,但得到一些错误,这是我使用的配置: -
调度员servlet.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:cache="http://www.springframework.org/schema/cache"
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">
<cache:annotation-driven />
<bean id="defaultEhCacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="/WEB-INF/ehcache.xml" p:shared="false"></bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"></property>
</bean>
<cache:annotation-driven cache-manager="cacheManager" />
<bean id="cacheManager">
<property name="cacheManager" ref="ehcache" />
</bean>
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="/WEB-INF/ehcache.xml" />
</bean>
Run Code Online (Sandbox Code Playgroud)
ehcache.xml中
<cache name="sampleCache1"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="300"
timeToLiveSeconds="600">
</cache>
Run Code Online (Sandbox Code Playgroud)
这是依赖: -
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.5.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误: -
重度:上下文初始化失败org.springframework.beans.factory.BeanCreationException:错误创建名称为豆"org.springframework.cache.interceptor.CacheInterceptor#0":无法解析参考豆"的CacheManager"而设置的bean属性"的CacheManager"; 嵌套的例外是org.springframework.beans.factory.BeanCreationException:错误创建名称为豆"的CacheManager"在ServletContext的资源定义[/WEB-INF/dispatcher-servlet.xml]:无法解析参考豆"的Ehcache"而设置的bean属性'的CacheManager'; 嵌套的例外是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为"的Ehcache"豆是指在确定
请尽快建议任何解决方案.
提前致谢
String str=(37.028994, 35.26719589999993);
Run Code Online (Sandbox Code Playgroud)
我必须在单独的变量中检索这些.可以帮助获取这些值吗?
例如,输出应为以下类型.
a=37.028994
b=35.26719589999993
Run Code Online (Sandbox Code Playgroud)
提前致谢!!!