我有下一种情况:
Connection manager应该每次都有一个对象ConnectionServer和新对象的DataBean
So,我已经创建了这些bean并配置了它的spring xml.
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="dataBena" class="com.test.DataBean" scope="prototype"/>
<bean id="servCon" class="com.test.ServerCon"/>
<!--<bean id="test" class="com.test.Test"/>-->
<context:component-scan base-package="com.test"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
并添加范围prototype为DataBean
在此之后,我创建了名为Test的简单util/component类
@Component
public class Test {
@Autowired
private DataBean bean;
@Autowired
private ServerCon server;
public DataBean getBean() {
return bean.clone();
}
public ServerCon getServer() {
return server;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,每次调用getBean()方法我都会克隆这个bean,这对我来说是个问题.我可以在没有克隆方法的情况下从spring配置中做到吗?谢谢.
在阅读Netty教程时,我发现了如何集成Netty和Google Protocol Buffers的简单描述.我已经开始研究它的例子(因为文档中没有更多的信息)并编写了一个简单的应用程序,如示例本地时间应用程序.但是这个例子是在PipeFactory类中使用静态初始化,例如:
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder;
import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder;
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
import static org.jboss.netty.channel.Channels.pipeline;
/**
* @author sergiizagriichuk
*/
class ProtoCommunicationClientPipeFactory implements ChannelPipelineFactory {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline p = pipeline();
p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
p.addLast("protobufDecoder", new ProtobufDecoder(Communication.DataMessage.getDefaultInstance()));
p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("handler", new ProtoCommunicationClientHandler());
return p;
}
}
Run Code Online (Sandbox Code Playgroud)
(请看一下p.addLast("protobufDecoder", new ProtobufDecoder(Communication.DataMessage.getDefaultInstance()));),只有一个工厂可以创建(据我所知)ClientBootstrap,我的意思是bootstrap.setPipelineFactory()方法.所以,在这种情况下,我可以使用ONE 消息发送给服务器,并ONE消息从服务器接收,这是对我不好,我想不只是我:(我如何使用不同的信息,并从其只是一个连接?也许我可以创造一些protobufDecoder像这样的东西
p.addLast("protobufDecoder", new ProtobufDecoder(Communication.DataMessage.getDefaultInstance()));
p.addLast("protobufDecoder", …Run Code Online (Sandbox Code Playgroud) 几天前我在一家大公司接受采访,名字不是必需的:),面试官让我找到下一个任务的解决方案:
预定义: 有未指定大小的单词字典,我们只知道字典中的所有单词都被排序(例如按字母表).我们也只有一种方法
String getWord(int index) throws IndexOutOfBoundsException
Run Code Online (Sandbox Code Playgroud)
需求: 需要开发算法以使用java在字典中查找某些输入词.为此我们应该实现方法
public boolean isWordInTheDictionary(String word)
Run Code Online (Sandbox Code Playgroud)
局限性: 我们无法改变字典的内部结构,我们无法访问内部结构,我们不知道字典中的元素数量.
问题: 我已经开发了修改二分法搜索,并将发布我的算法变体(工程变体),但是还有其他具有对数复杂度的变体吗?我的变体有复杂度O(logN).
我的实施变体:
public class Dictionary {
private static final int BIGGEST_TOP_MASK = 0xF00000;
private static final int LESS_TOP_MASK = 0x0F0000;
private static final int FULL_MASK = 0xFFFFFF;
private String[] data;
private static final int STEP = 100; // for real test step should be Integer.MAX_VALUE
private int shiftIndex = -1;
private static final int LESS_MASK = 0x0000FF;
private static …Run Code Online (Sandbox Code Playgroud) 我需要查看我的应用程序的内存大小,CPU使用率等,发现zabbix作为监视工具,并希望在zabbix和我的应用程序之间创建桥梁.我不想在JMX MBean中添加额外的模块.是否有一些用于创建桥梁的实现/解决方案?我想复制一些罐子/罐子我的班级路径,看看一般的监控信息.非常感谢.
我已将默认(IntellJ IDEA)键映射应用于Visual Studion,并希望将某些映射更改为我的自定义,例如Generate Code(Alt + Ins).我怎么能这样做或者这是不可能的.
PSVisual Studio 2010,Resharper 6.1
是否有IntelJ IDEA这样的色彩风格http://studiostyl.es/schemes/coding-horror-2010?我在VS中使用过这种风格,可以说它非常酷!谢谢
我收到了另一个团队的一些代码,并开始进行简单的改进和重新分解.第一阶段是为项目添加单元测试.我需要测试解析输入短信的功能.与上述信息相关,我的问题是: - 我可以通过测试方法将短信发送到模拟器端口吗?我写了下一个代码,但没有收到任何东西......
@Test
public void sendSmsTest() {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("5554", null, getSms("sms1"), null, null);
}
private String getSms(String smsKey) {
return (String) smsMessages.get(smsKey);
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
重新启动模拟器和IDE后,我在控制台中收到了下一个错误:
测试运行失败:ComponentInfo的onCreate()抛出异常{com.example/android.test.InstrumentationTestRunner}:java.lang.NullPointerException
有简单的代码
int a( int *p0 ) {
int p;
if( p0 ) return p0 > &p;
return a(&p);
}
int main() {
puts( a(0) ? "y" : "n" );
}
Run Code Online (Sandbox Code Playgroud)
结果将是什么以及a将调用多少次方法?
java ×6
spring ×2
algorithm ×1
android ×1
aspectj ×1
c++ ×1
cloning ×1
color-scheme ×1
filesystems ×1
fuse ×1
jmx ×1
logging ×1
monitoring ×1
netty ×1
resharper ×1
static ×1
styles ×1
unit-testing ×1
windows ×1
zabbix ×1