Commit 5ce33830 authored by Java-刘 彧阳's avatar Java-刘 彧阳

增加代码

parent 5cbc2276
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
package cn.quantgroup.fs;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmListener;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.apache.commons.pool2.impl.GenericObjectPool;
/**
* Created by Miraculous on 16/7/3.
*/
public class ChannelPool {
private GenericObjectPool<Channel> pool;
private Connection connection = null;
private void init(ConfirmListener confirmListener) {
try {
PropertyHolder propertyHolder = new PropertyHolder();
String rabbitHost = propertyHolder.getProperty("fs.rabbitmq.host");
int rabbitPort = Integer.parseInt(propertyHolder.getProperty("fs.rabbitmq.port"));
String user = propertyHolder.getProperty("fs.rabbitmq.user");
String password = propertyHolder.getProperty("fs.rabbitmq.password");
String vhost = propertyHolder.getProperty("fs.rabbitmq.vhost");
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername(user);
factory.setPassword(password);
factory.setVirtualHost(vhost);
factory.setHost(rabbitHost);
factory.setPort(rabbitPort);
factory.setAutomaticRecoveryEnabled(true);
factory.setConnectionTimeout(20000);
connection = factory.newConnection();
ChannelPoolFactory cf = new ChannelPoolFactory(connection, confirmListener);
pool = new GenericObjectPool<>(cf);
pool.setMaxTotal(100);
pool.setMaxWaitMillis(30000);
pool.setMaxIdle(8);
pool.setMinIdle(2);
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
protected ChannelPool(ConfirmListener confirmableMsgListener) {
init(confirmableMsgListener);
}
public Channel borrowObject() throws Exception {
return pool.borrowObject();
}
public void returnObject(Channel channel) throws Exception {
pool.returnObject(channel);
}
public void close() {
try {
//關閉 Pool
pool.close();
//關閉rabbitmq connection
this.connection.close();
} catch (Exception e) {
// logger.error("error:", e);
}
}
}
package cn.quantgroup.fs;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmListener;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
/**
* Created by Miraculous on 16/7/3.
*/
public class ChannelPoolFactory extends BasePooledObjectFactory<Channel> {
private Connection connection;
private ConfirmListener confirmListener;
public ChannelPoolFactory(Connection c) {
this(c, null);
}
public ChannelPoolFactory(Connection c, ConfirmListener confirmListener) {
this.connection = c;
this.confirmListener = confirmListener;
}
@Override
public Channel create() throws Exception {
Channel channel = connection.createChannel();
if (this.confirmListener != null) {
channel.addConfirmListener(confirmListener);
}
return channel;
}
@Override
public PooledObject<Channel> wrap(Channel channel) {
return new DefaultPooledObject<>(channel);
}
@Override
public void passivateObject(PooledObject<Channel> p) throws Exception {
super.passivateObject(p);
}
@Override
public boolean validateObject(PooledObject<Channel> p) {
Channel channel = p.getObject();
return channel.isOpen();
}
@Override
public void destroyObject(PooledObject<Channel> p) throws Exception {
p.getObject().close();
}
}
package cn.quantgroup.fs;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* Created by Miraculous on 16/6/30.
*/
class PropertyHolder {
private Properties properties = new Properties();
public PropertyHolder() {
InputStream stream = null;
try {
stream = PropertyHolder.class.getResourceAsStream("/config.properties");
properties.load(stream);
} catch (IOException e) {
System.out.println("fs can not init, reason: " + e.getMessage());
System.exit(-1);
} finally {
if (null != stream) {
try {
stream.close();
} catch (IOException e) {
// ignore
}
}
}
}
public String getProperty(String propertyName) {
if (!properties.containsKey(propertyName)) {
System.out.println("can not find property with name in fs sdk: " + propertyName);
System.exit(-1);
}
return properties.getProperty(propertyName);
}
}
sms.rabbitmq.host=192.168.192.243 fs.rabbitmq.host=192.168.192.243
sms.rabbitmq.port=5672 fs.rabbitmq.port=5672
sms.rabbitmq.user=rabbit_admin fs.rabbitmq.user=rabbit_admin
sms.rabbitmq.password=abc1234 fs.rabbitmq.password=abc1234
sms.rabbitmq.exchange-name=sms-control fs.rabbitmq.exchange-name=fs-control
sms.rabbitmq.vhost=sms fs.rabbitmq.vhost=fs
\ No newline at end of file \ No newline at end of file
sms.rabbitmq.host=192.168.192.243 fs.rabbitmq.host=192.168.192.243
sms.rabbitmq.port=5672 fs.rabbitmq.port=5672
sms.rabbitmq.user=rabbit_admin fs.rabbitmq.user=rabbit_admin
sms.rabbitmq.password=abc1234 fs.rabbitmq.password=abc1234
sms.rabbitmq.exchange-name=sms-control fs.rabbitmq.exchange-name=fs-control
sms.rabbitmq.vhost=sms fs.rabbitmq.vhost=fs
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment