小编Kra*_*ayo的帖子

哪个更好:PooledConnectionFactory或CachingConnectionFactory?

我们在Tomcat(7.0.41)中使用Spring(3.2.4)和ActiveMQ(5.8.0)并且不清楚最佳用法是什么.我们希望使用JmsTemplate生成MessageListenerContainer来接收消息.

我们应该在接收方使用缓存吗?(相关链接)
使用ActiveMQ和故障转移工作CachingConnectionFactory?(相关链接)
当我们使用PooledConnectionFactory时需要设置useAsyncSend ="true"吗?(相关链接)

java spring tomcat activemq-classic jms

27
推荐指数
1
解决办法
3万
查看次数

Vaadin从按钮点击重定向到URL

我已经搜索了很长时间,但我真的无法弄清楚这一点.

如何在用户单击Vaadin中的按钮时将用户重定向到新的外部链接(例如www.google.com)?

到目前为止,我唯一能做的就是将链接放入链接中

Link link = new Link("link", new ExternalResource("http://www.google.com"));
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

java vaadin

8
推荐指数
1
解决办法
1万
查看次数

传递参数与从函数返回参数

从标题中可以清楚地看出我们应该采用哪种方法?

意图是传递一些方法参数并获得输出.我们可以传递另一个参数,方法会更新它,方法现在不需要返回任何东西,方法只会更新输出变量,它会反映给调用者.

我只想通过这个例子来构建问题.

List<String> result = new ArrayList<String>();

for (int i = 0; i < SOME_NUMBER_N; i++) {
    fun(SOME_COLLECTION.get(i), result);
}

// in some other class
public void fun(String s, List<String> result) {
    // populates result
}
Run Code Online (Sandbox Code Playgroud)

List<String> result = new ArrayList<String>();

for (int i = 0; i < SOME_NUMBER_N; i++) {
    List<String> subResult = fun(SOME_COLLECTION.get(i));
    // merges subResult into result
    mergeLists(result, subResult);
}

// in some other class
public List<String> fun(String s) {
    List<String> res = new ArrayList<String>(); …
Run Code Online (Sandbox Code Playgroud)

java parameter-passing pass-by-reference

7
推荐指数
2
解决办法
1万
查看次数

如何使用spring java配置在单例bean中生成原型对象

这就是我现在的工作正常.它所做的只是一个返回项目对象数组的市场类:

我有上课的市场

class market {

    public ArrayList<Items> createItems(HashMap<String,String> map) {
        ArrayList<Items> array = new ArrayList<Items>();
        for (Map.Entry<String, String> m : map.entrySet()) {
            Item item = new Item();
            item.setName(m.key());
            item.setValue(m.value());
            array.add(item);
        }
        return array;
    }
}
Run Code Online (Sandbox Code Playgroud)

class Item是带有getter和setter的名称和值的简单类

以下是我的配置文件的外观:

@Configuration
public class MarketConfig {

    @Bean
    public Market market() {
        return new Market();
    }
}
Run Code Online (Sandbox Code Playgroud)

我想如何改变我的代码:(原因:我不想要

Item item = new Item(); 
Run Code Online (Sandbox Code Playgroud)

在那时的方法.我希望Spring将它注入市场)

class market {

    public Item item;
    //getters and setters for item

    public ArrayList<Items> createItems(HashMap<String,String> map) {
        ArrayList<Items> array = new …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc java-ee

6
推荐指数
2
解决办法
2万
查看次数

Lob关闭了.ERRORCODE = -4470,SQLSTATE = null

我正在使用IBM websphere commerce和db2,有以下代码

Clob clobVar = null;
if (result.elementAt(3) != null)
    clobVar = (Clob) result.elementAt(3);

if (clobVar == null) {
    infoTable.put("EInfo", "");
} else {
    stringTemp = clobVar.getSubString(1, (int) clobVar.length());
    infoTable.put("EInfo", stringTemp); 
}
Run Code Online (Sandbox Code Playgroud)

代码工作正常,直到

clobVar = (Clob) result.elementAt(3);
Run Code Online (Sandbox Code Playgroud)

但是一旦执行就到了

stringTemp = clobVar.getSubString(1, (int) clobVar.length());
Run Code Online (Sandbox Code Playgroud)

系统抛出异常

[jcc] [10120] [11936] [4.3.111]无效操作:Lob关闭.ERRORCODE = -4470,SQLSTATE = null

我做错了什么?

如何解决这个问题?

java db2 websphere-commerce java-ee

6
推荐指数
1
解决办法
1万
查看次数

Vaadin表行改变最佳实践

在Vaadin(6和7)中替换表行的最佳方法是什么?我使用BeanItemContainer.bean是一个实体并且已经改变(不是ID).

我认为这会导致不必要的方法调用和/或对象创建:

table.removeItem( item );
table.addItem( item );
Run Code Online (Sandbox Code Playgroud)

vaadin

5
推荐指数
1
解决办法
4893
查看次数

在Vaadin 7中调用VaadinSession getAttribute时需要锁定

我知道调用setAttribute(link)时有必要,但getAttirbute呢?

它是否正确?

public Object getMyAttribute() {
    return VaadinSession.getCurrent().getAttribute("myAttribute");
}
Run Code Online (Sandbox Code Playgroud)

还是需要锁定?

public Object getMyAttribute() {
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        return VaadinSession.getCurrent().getAttribute("myAttribute");
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}
Run Code Online (Sandbox Code Playgroud)

java multithreading vaadin vaadin7

3
推荐指数
1
解决办法
2591
查看次数

eclipse IDE中的java程序编译错误

我有以下代码,其中eclipse给出以下编译错误:

Multiple markers at this line
- The hierarchy of the type TutorialsApplication is inconsistent
- The type com.vaadin.terminal.Terminal$ErrorListener cannot be resolved. It is indirectly referenced 
 from required .class files
- The type com.vaadin.terminal.URIHandler cannot be resolved. It is indirectly referenced from 
 required .class files
Run Code Online (Sandbox Code Playgroud)

我的代码是:

package com.example.tutorials;

import com.example.component.Window.HomeWindow;
import com.vaadin.Application;

@SuppressWarnings("serial")
public class TutorialsApplication extends Application {
    // @Override
    public void init() {
        HomeWindow main = new HomeWindow("Welcome to FunFusion Content Management System");
        setMainWindow(main);
        main.initWindow();
    }
}
Run Code Online (Sandbox Code Playgroud)

java web-applications vaadin

2
推荐指数
1
解决办法
1788
查看次数

将参数传递给vaadin 7 Web应用程序

我正在使用vaadin6,所以我使用以下方法来检索Web应用程序参数:

public abstract class Application implements URIHandler,
        Terminal.ErrorListener, Serializable {

    /**
     * Searches for the property with the specified name in this application.
     * This method returns <code>null</code> if the property is not found.
     * 
     * See {@link #start(URL, Properties, ApplicationContext)} how properties
     * are defined.
     * 
     * @param name
     *            the name of the property.
     * @return the value in this property list with the specified key value.
     */
    public String getProperty(String name) {
        return properties.getProperty(name);
    }

    //...
} …
Run Code Online (Sandbox Code Playgroud)

vaadin vaadin7

2
推荐指数
1
解决办法
1117
查看次数

在Java中使用通配符

import java.util.ArrayList;
import java.util.List;

public class WildCardNumber {

    public static void main(String[] args) {
        List<EvenNumber> le = new ArrayList<>();
        List<? extends NaturalNumber> ln = le;
        ln.add(new NaturalNumber(50));//  *   Compile time error
        ln.add(new EvenNumber(46));   // **   Compile time error 
    }

}

class NaturalNumber {

    private int n;

    public NaturalNumber(int n) {
        this.n = n;
    }

}

class EvenNumber extends NaturalNumber {

    public EvenNumber(int n) {
        super(n);
    }

}
Run Code Online (Sandbox Code Playgroud)

在Oracle文档中学习通配符时,我找到了上述代码.

根据源,变量"ln"不能接受任何"NaturalNumber",因为它是"EvenNumber"内容的列表.我尝试添加一个"EvenNumber"对象.这也是不被接受的.

似乎变量"ln"是文档中提到的只读对象.你们可以解释为什么这个对象是只读的吗?(我可以添加空值)如果我们不能添加"NaturalNumber",为什么我们不能添加"EvenNumber"呢?因为根据Wildcard我们已经指定,变量"ln"可以接受"NaturalNumber"的子类型,而"EvenNumber"是子类型吗?

java generics wildcard

2
推荐指数
1
解决办法
66
查看次数

"主要方法不公开" - 尝试在Eclipse上运行程序时出现错误消息

这是我在Eclipse上使用的代码我不明白我哪里出错了.我是Java初学者,所以我不太熟悉这个主题.任何帮助将非常感激.当我尝试通过运行程序看到我走了多远时,错误始终存在,轻松的计算机行话请我是新来的这个大声笑.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;

public class CBombRombot extends JFrame implements ActionListener, ChangeListener {

    private JPanel panel;
    private JPanel bottompanel;
    private JPanel rightpanel;

    private static void main(String[] args) {
        CBombRombot frame = new CBombRombot();
        frame.setTitle("CBombRobot Application");
        frame.setSize(875, 550);
        frame.show();
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
    }

    private void createGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container window = getContentPane();
        window.setLayout(new BorderLayout());

        panel = new JPanel();
        panel.setPreferredSize(new Dimension(650, 450));
        panel.setBackground(Color.white);
        window.add(panel);

        rightpanel = new JPanel();
        rightpanel.setPreferredSize(new Dimension(200, 180));
        rightpanel.setBackground(Color.lightGray); …
Run Code Online (Sandbox Code Playgroud)

java program-entry-point class

0
推荐指数
1
解决办法
975
查看次数