From de39552e4dbb8840423701dbf6d4072f9a1ac661 Mon Sep 17 00:00:00 2001 From: Maciej Swiderski Date: Thu, 26 Apr 2012 20:19:44 +0200 Subject: [PATCH] added hornetq support for human task view, configurable in preferences panel --- .../META-INF/MANIFEST.MF | 4 ++- drools-eclipse/org.jbpm.eclipse.task/pom.xml | 28 ++++++++----------- .../task/preferences/TaskConstants.java | 1 + .../task/preferences/TaskPreferencePage.java | 15 ++++++++++ .../org/jbpm/eclipse/task/views/TaskView.java | 25 ++++++++++++++--- 5 files changed, 52 insertions(+), 21 deletions(-) diff --git a/drools-eclipse/org.jbpm.eclipse.task/META-INF/MANIFEST.MF b/drools-eclipse/org.jbpm.eclipse.task/META-INF/MANIFEST.MF index d1edc9273..c9ebf93d7 100644 --- a/drools-eclipse/org.jbpm.eclipse.task/META-INF/MANIFEST.MF +++ b/drools-eclipse/org.jbpm.eclipse.task/META-INF/MANIFEST.MF @@ -15,5 +15,7 @@ Bundle-ClassPath: ., lib/mina-core.jar, lib/slf4j-api.jar, lib/slf4j-jdk14.jar, - lib/jbpm-human-task.jar + lib/jbpm-human-task.jar, + lib/hornetq-core.jar, + lib/netty.jar Bundle-Vendor: JBoss by Red Hat diff --git a/drools-eclipse/org.jbpm.eclipse.task/pom.xml b/drools-eclipse/org.jbpm.eclipse.task/pom.xml index 95e387ba3..b8ce9b130 100644 --- a/drools-eclipse/org.jbpm.eclipse.task/pom.xml +++ b/drools-eclipse/org.jbpm.eclipse.task/pom.xml @@ -67,7 +67,9 @@ mina-core, slf4j-api, slf4j-jdk14, - jbpm-human-task + jbpm-human-task, + hornetq-core, + netty @@ -154,23 +156,17 @@ commons-collections - - org.hornetq - hornetq-core - - - - org.hornetq - hornetq-transports - - - - org.jboss.netty - netty - - + + org.hornetq + hornetq-core + + + org.jboss.netty + netty + 3.2.0.Final + diff --git a/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskConstants.java b/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskConstants.java index 5a60e4ce2..f8c520eab 100644 --- a/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskConstants.java +++ b/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskConstants.java @@ -21,5 +21,6 @@ public interface TaskConstants { String SERVER_IP_ADDRESS = "ServerIPAddress"; String SERVER_PORT = "ServerPort"; String LANGUAGE = "Language"; + String TRANSPORT = "Transport"; } diff --git a/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskPreferencePage.java b/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskPreferencePage.java index e2f1db8e5..817394912 100644 --- a/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskPreferencePage.java +++ b/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/preferences/TaskPreferencePage.java @@ -20,6 +20,7 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; @@ -33,11 +34,13 @@ public class TaskPreferencePage extends PreferencePage implements IWorkbenchPref private Text ipAddressText; private Text portText; private Text languageText; + private Combo transportType; protected Control createContents(Composite parent) { ipAddressText = createText(parent, "IP address"); portText = createText(parent, "Port"); languageText = createText(parent, "Language"); + transportType = createCombo(parent, "Transport"); initializeValues(); return new Composite(parent, SWT.NULL); } @@ -48,6 +51,15 @@ private Text createText(Composite group, String labelText) { Text text = new Text(group, SWT.NONE); return text; } + + private Combo createCombo(Composite group, String labelText) { + Label label = new Label(group, SWT.NONE); + label.setText(labelText); + Combo combo = new Combo(group, SWT.NONE); + combo.add("mina", 0); + combo.add("hornetq", 1); + return combo; + } protected IPreferenceStore doGetPreferenceStore() { return Activator.getDefault().getPreferenceStore(); @@ -58,6 +70,7 @@ private void initializeDefaults() { ipAddressText.setText(store.getDefaultString(TaskConstants.SERVER_IP_ADDRESS)); portText.setText(store.getDefaultInt(TaskConstants.SERVER_PORT) + ""); languageText.setText(store.getDefaultString(TaskConstants.LANGUAGE)); + transportType.select(store.getInt(TaskConstants.TRANSPORT)); } private void initializeValues() { @@ -65,6 +78,7 @@ private void initializeValues() { ipAddressText.setText(store.getString(TaskConstants.SERVER_IP_ADDRESS)); portText.setText(store.getInt(TaskConstants.SERVER_PORT) + ""); languageText.setText(store.getString(TaskConstants.LANGUAGE)); + transportType.select(store.getInt(TaskConstants.TRANSPORT)); } protected void performDefaults() { @@ -85,6 +99,7 @@ private void storeValues() { store.setValue(TaskConstants.SERVER_IP_ADDRESS, ipAddressText.getText()); store.setValue(TaskConstants.SERVER_PORT, port); store.setValue(TaskConstants.LANGUAGE, languageText.getText()); + store.setValue(TaskConstants.TRANSPORT, transportType.getSelectionIndex()); } catch (NumberFormatException e) { showMessage("Could not convert port, should be an integer value."); } diff --git a/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/views/TaskView.java b/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/views/TaskView.java index c8f00bd42..6ce0d2257 100644 --- a/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/views/TaskView.java +++ b/drools-eclipse/org.jbpm.eclipse.task/src/main/java/org/jbpm/eclipse/task/views/TaskView.java @@ -69,6 +69,8 @@ import org.jbpm.task.User; import org.jbpm.task.query.TaskSummary; import org.jbpm.task.service.TaskClient; +import org.jbpm.task.service.hornetq.HornetQTaskClientConnector; +import org.jbpm.task.service.hornetq.HornetQTaskClientHandler; import org.jbpm.task.service.mina.MinaTaskClientConnector; import org.jbpm.task.service.mina.MinaTaskClientHandler; @@ -106,6 +108,7 @@ public class TaskView extends ViewPart { private String ipAddress = "127.0.0.1"; private int port = 9123; private String language = "en-UK"; + private int transport = 0; private Text userNameText; private Table table; @@ -179,6 +182,7 @@ public TaskView() { ipAddress = preferenceStore.getString(TaskConstants.SERVER_IP_ADDRESS); port = preferenceStore.getInt(TaskConstants.SERVER_PORT); language = preferenceStore.getString(TaskConstants.LANGUAGE); + transport = preferenceStore.getInt(TaskConstants.TRANSPORT); preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (TaskConstants.SERVER_IP_ADDRESS.equals(event.getProperty())) { @@ -187,6 +191,8 @@ public void propertyChange(PropertyChangeEvent event) { port = (Integer) event.getNewValue(); } else if (TaskConstants.LANGUAGE.equals(event.getProperty())) { language = (String) event.getNewValue(); + } else if (TaskConstants.TRANSPORT.equals(event.getProperty())) { + transport = (Integer) event.getNewValue(); } } }); @@ -687,12 +693,23 @@ public void fail() { } private TaskClient getTaskClient() { - if (client == null) { - client = new TaskClient(new MinaTaskClientConnector("client 1", - new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); + + if (client == null) { + String transportType = "unknown"; + if (transport == 0) { + transportType = "Apache Mina"; + client = new TaskClient(new MinaTaskClientConnector("client 1", + new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); + + } else if (transport == 1) { + transportType = "HornetQ"; + client = new TaskClient(new HornetQTaskClientConnector("client 1", + new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); + + } boolean connected = client.connect(ipAddress, port); if (!connected) { - showMessage("Could not connect to task server: " + ipAddress + " [port " + port + "]"); + showMessage("Could not connect to task server: " + ipAddress + " [port " + port + "] transport " + transportType); client = null; } }