diff options
author | rbrooks | 2010-07-24 17:38:31 +0000 |
---|---|---|
committer | rbrooks | 2010-07-24 17:38:31 +0000 |
commit | 4081f04850d3eff9eb1bd7241763707bfbb43a45 (patch) | |
tree | 258620df94d4b24077ff103a6c4dea9cb78493fb /plugins/org.eclipse.osee.framework.messaging/src/org/eclipse | |
parent | 4ed8bddc791fda93940f238c5135556a07041dc0 (diff) | |
download | org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.gz org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.xz org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.zip |
applied Eclipse source cleanup
Diffstat (limited to 'plugins/org.eclipse.osee.framework.messaging/src/org/eclipse')
51 files changed, 867 insertions, 824 deletions
diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ComponentListener.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ComponentListener.java index 5f4bc4eb5ba..14ab465793c 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ComponentListener.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ComponentListener.java @@ -12,11 +12,11 @@ package org.eclipse.osee.framework.messaging; /** * @author Andrew M. Finkbeiner - * */ public interface ComponentListener { - + void onComponentAvailable(Component component); + void onComponentNotAvailable(Component component); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionListener.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionListener.java index df187a6656e..7880613d06a 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionListener.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionListener.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.framework.messaging; - /** * @author Andrew M. Finkbeiner - * */ public interface ConnectionListener { void connected(ConnectionNode node); + void notConnected(ConnectionNode node); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNode.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNode.java index fcca38bb1b6..4c53671bb69 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNode.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNode.java @@ -11,7 +11,6 @@ package org.eclipse.osee.framework.messaging; import java.util.Properties; - import org.eclipse.osee.framework.core.exception.OseeCoreException; /** @@ -21,82 +20,96 @@ public interface ConnectionNode { /** * Subscribes listener to updates to message/s with the given id. + * * @param messageId * @param listener * @param statusCallback Used to relay the status of the subscribe command ( success, failure, etc). Can not be null. */ void subscribe(MessageID messageId, OseeMessagingListener listener, final OseeMessagingStatusCallback statusCallback); - + /** * Subscribes listener to updates to message/s with the given id. + * * @param messageId * @param listener * @param selector A string conforming to the SQL 92 syntax used for extra filtering of subscriptions * @param statusCallback Used to relay the status of the subscribe command ( success, failure, etc). Can not be null. */ void subscribe(MessageID messageId, OseeMessagingListener listener, String selector, final OseeMessagingStatusCallback statusCallback); - + /** - * Subscribes listener to updates to message/s with the given id. A default status - * handler will be used to log failures. + * Subscribes listener to updates to message/s with the given id. A default status handler will be used to log + * failures. + * * @param messageId * @param listener */ void subscribe(MessageID messageId, OseeMessagingListener listener); - + /** * Unsubscribes listener from updates for message with id equal to messageId. + * * @param messageId * @param listener * @param statusCallback Used to relay the status of the unsubscribe ( success, failure, etc). Can not be null. */ void unsubscribe(MessageID messageId, OseeMessagingListener listener, final OseeMessagingStatusCallback statusCallback); - + /** - * Unsubscribes listener from updates for message with id equal to messageId. A default status - * handler will be used to log failures. + * Unsubscribes listener from updates for message with id equal to messageId. A default status handler will be used + * to log failures. + * * @param messageId * @param listener */ void unsubscribe(MessageID messageId, OseeMessagingListener listener); boolean subscribeToReply(MessageID messageId, OseeMessagingListener listener); + boolean unsubscribteToReply(MessageID messageId, OseeMessagingListener listener); - + /** * Sends given message. + * * @param messageId * @param message - * @param statusCallback Used to relay the status of the sending of the message ( success, failure, etc). Can not be null. + * @param statusCallback Used to relay the status of the sending of the message ( success, failure, etc). Can not be + * null. * @throws OseeCoreException */ void send(MessageID messageId, Object message, final OseeMessagingStatusCallback statusCallback) throws OseeCoreException; - + /** * Attaches the properties provided to the message before sending. + * * @param messageId * @param message * @param properties Set of properties to be attached to the message. - * @param statusCallback Used to relay the status of the sending of the message ( success, failure, etc). Can not be null. + * @param statusCallback Used to relay the status of the sending of the message ( success, failure, etc). Can not be + * null. * @throws OseeCoreException */ void send(MessageID messageId, Object message, Properties properties, OseeMessagingStatusCallback statusCallback) throws OseeCoreException; /** - * Sends given message. Uses default status handler to log failures in sending given message. + * Sends given message. Uses default status handler to log failures in sending given message. + * * @param messageId * @param message * @throws OseeCoreException */ void send(MessageID messageId, Object message) throws OseeCoreException; - + void addConnectionListener(ConnectionListener connectionListener); + void removeConnectionListener(ConnectionListener connectionListener); void stop(); String getSummary(); + String getSubscribers(); + String getSenders(); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFactory.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFactory.java index 79cc90c2a17..f876648fb8d 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFactory.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFactory.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.framework.messaging; - /** * @author Roberto E. Escobar */ public interface ConnectionNodeFactory { ConnectionNode create(NodeInfo nodeInfo); - + } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFailoverSupport.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFailoverSupport.java index f9e8099a636..3e2b6783121 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFailoverSupport.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ConnectionNodeFailoverSupport.java @@ -14,9 +14,9 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; /** * @author Andrew M. Finkbeiner - * */ public interface ConnectionNodeFailoverSupport extends ConnectionNode { boolean isConnected(); + public void start() throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/EndpointReceive.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/EndpointReceive.java index d4cf0827157..3971c134802 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/EndpointReceive.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/EndpointReceive.java @@ -24,7 +24,7 @@ import org.eclipse.osee.framework.messaging.internal.old.ApplicationDistributer; public abstract class EndpointReceive { private ApplicationDistributer distributer; - private ExecutorService executor; + private final ExecutorService executor; public EndpointReceive() { executor = Executors.newSingleThreadExecutor(); @@ -51,9 +51,9 @@ public abstract class EndpointReceive { protected void onReceive(final Message message) { if (distributer == null) { String errorMsg = - String.format( - "We have recieved message [%s] from [%s], but have no active ApplicationDistributer available.", - message.getId().toString(), message.getSource().toString()); + String.format( + "We have recieved message [%s] from [%s], but have no active ApplicationDistributer available.", + message.getId().toString(), message.getSource().toString()); OseeLog.log(Activator.class, Level.WARNING, errorMsg); } else { executor.execute(new Runnable() { diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageID.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageID.java index f6807a089a0..372326e6717 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageID.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageID.java @@ -14,11 +14,13 @@ import org.eclipse.osee.framework.core.data.Named; /** * @author Andrew M. Finkbeiner - * */ public interface MessageID extends Named { - Class<?> getSerializationClass(); - boolean isReplyRequired(); - boolean isTopic(); - String getId(); + Class<?> getSerializationClass(); + + boolean isReplyRequired(); + + boolean isTopic(); + + String getId(); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageService.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageService.java index d8e6ad2c1ac..ef8a918e4c1 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageService.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessageService.java @@ -11,7 +11,6 @@ package org.eclipse.osee.framework.messaging; import java.util.Collection; - import org.eclipse.osee.framework.core.exception.OseeCoreException; /** @@ -19,12 +18,12 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; */ public interface MessageService { - ConnectionNode getDefault() throws OseeCoreException; - + ConnectionNode getDefault() throws OseeCoreException; + ConnectionNode get(NodeInfo nodeInfo) throws OseeCoreException; Collection<NodeInfo> getAvailableConnections(); - + int size(); boolean isEmpty(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessagingTracker.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessagingTracker.java index 1761618ee51..6d9f1836dbe 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessagingTracker.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/MessagingTracker.java @@ -10,18 +10,16 @@ *******************************************************************************/ package org.eclipse.osee.framework.messaging; - import org.eclipse.osee.framework.messaging.internal.Activator; import org.osgi.util.tracker.ServiceTracker; /** * @author Andrew M. Finkbeiner - * */ public class MessagingTracker extends ServiceTracker { - public MessagingTracker() { - super(Activator.getInstance().getContext(), OseeMessaging.class.getName(), null); - } + public MessagingTracker() { + super(Activator.getInstance().getContext(), OseeMessaging.class.getName(), null); + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/NodeInfo.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/NodeInfo.java index 3b2ca18fe49..807dcb31547 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/NodeInfo.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/NodeInfo.java @@ -13,72 +13,82 @@ package org.eclipse.osee.framework.messaging; import java.io.Serializable; import java.net.URI; - /** * @author Roberto E. Escobar */ public class NodeInfo implements Serializable { - private final URI uri; - private final String name; - private String nameWithColon; + /** + * + */ + private static final long serialVersionUID = -5245181117185581620L; + private final URI uri; + private final String name; + private final String nameWithColon; - public NodeInfo(String name, URI uri) { - this.uri = uri; - this.name = name; - nameWithColon = name + ":"; - } + public NodeInfo(String name, URI uri) { + this.uri = uri; + this.name = name; + nameWithColon = name + ":"; + } - public URI getUri() { - return uri; - } + public URI getUri() { + return uri; + } - @Override - public String toString() { - return name + ":" + uri; - } + @Override + public String toString() { + return name + ":" + uri; + } - public String getComponentName() { - return name; - } + public String getComponentName() { + return name; + } - public String getComponentNameForRoutes() { - return nameWithColon; - } + public String getComponentNameForRoutes() { + return nameWithColon; + } - public boolean isVMComponent() { - return getComponentName().equals(Component.VM.getComponentName()); - } + public boolean isVMComponent() { + return getComponentName().equals(Component.VM.getComponentName()); + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((uri == null) ? 0 : uri.hashCode()); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (name == null ? 0 : name.hashCode()); + result = prime * result + (uri == null ? 0 : uri.hashCode()); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NodeInfo other = (NodeInfo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (uri == null) { - if (other.uri != null) - return false; - } else if (!uri.equals(other.uri)) - return false; - return true; - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + NodeInfo other = (NodeInfo) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (uri == null) { + if (other.uri != null) { + return false; + } + } else if (!uri.equals(other.uri)) { + return false; + } + return true; + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessaging.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessaging.java index fc6526aa48f..fc227cf29c6 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessaging.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessaging.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.framework.messaging; - /** * @author Andrew M. Finkbeiner */ diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingListener.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingListener.java index e68ff812962..d1736657c48 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingListener.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingListener.java @@ -17,19 +17,19 @@ import java.util.Map; */ public abstract class OseeMessagingListener { - private Class<?> clazz; - - public OseeMessagingListener() { - this.clazz = null; - } + private final Class<?> clazz; - public OseeMessagingListener(Class<?> clazz) { - this.clazz = clazz; - } + public OseeMessagingListener() { + this.clazz = null; + } - public Class<?> getClazz(){ - return clazz; - } - - public abstract void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection); + public OseeMessagingListener(Class<?> clazz) { + this.clazz = clazz; + } + + public Class<?> getClazz() { + return clazz; + } + + public abstract void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingStatusCallback.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingStatusCallback.java index 5f6b0ca634d..bd3675cf439 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingStatusCallback.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/OseeMessagingStatusCallback.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.framework.messaging; - /** * @author Andrew M. Finkbeiner - * */ public interface OseeMessagingStatusCallback { - void success(); - void fail(Throwable th); + void success(); + + void fail(Throwable th); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ReplyConnection.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ReplyConnection.java index 0549545a146..d7d50bb6bae 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ReplyConnection.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/ReplyConnection.java @@ -14,9 +14,9 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; /** * @author Andrew M. Finkbeiner - * */ public interface ReplyConnection { - public boolean isReplyRequested(); - public void send(Object body, Class<?> clazz, final OseeMessagingStatusCallback statusCallback) throws OseeCoreException; + public boolean isReplyRequested(); + + public void send(Object body, Class<?> clazz, final OseeMessagingStatusCallback statusCallback) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/SystemTopic.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/SystemTopic.java index 1227c41f1e7..909b1621a6c 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/SystemTopic.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/SystemTopic.java @@ -15,34 +15,34 @@ package org.eclipse.osee.framework.messaging; */ public enum SystemTopic implements MessageID { - JMS_HEALTH_STATUS("jms.health.status"), - KILL_TEST_JMS_BROKER("jms.kill.broker"); - - private String name; - - SystemTopic(String name) { - this.name = name; - } - - @Override - public String getName() { - return name; - } - - @Override - public Class<?> getSerializationClass() { - return null; - } - - @Override - public boolean isReplyRequired() { - return false; - } - - @Override - public String getId() { - return name; - } + JMS_HEALTH_STATUS("jms.health.status"), + KILL_TEST_JMS_BROKER("jms.kill.broker"); + + private String name; + + SystemTopic(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public Class<?> getSerializationClass() { + return null; + } + + @Override + public boolean isReplyRequired() { + return false; + } + + @Override + public String getId() { + return name; + } @Override public boolean isTopic() { diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/definitions/PropertyStoreMessage.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/definitions/PropertyStoreMessage.java index a93a176000c..8cb6600628c 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/definitions/PropertyStoreMessage.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/definitions/PropertyStoreMessage.java @@ -11,35 +11,33 @@ package org.eclipse.osee.framework.messaging.definitions; import java.io.Serializable; - import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.framework.messaging.Message; import org.eclipse.osee.framework.messaging.Source; import org.eclipse.osee.framework.messaging.id.MessageId; /** - * @author Michael P. Masterson + * @author Michael P. Masterson */ public class PropertyStoreMessage implements Message, Serializable { private static final long serialVersionUID = -8736301654726742145L; - - private MessageId messageId; - private Source source; - private PropertyStore store; - public PropertyStoreMessage(MessageId messageId, Source source) - { + private final MessageId messageId; + private final Source source; + private final PropertyStore store; + + public PropertyStoreMessage(MessageId messageId, Source source) { this.messageId = messageId; this.source = source; this.store = new PropertyStore("org.eclipse.osee.framework.messaging.definitions.PropertyStoreMessage"); } - + @Override public String toString() { return String.format("PropertyStoreMessage\t[MessageId: %s]\t[source: %s]", messageId, source); } - + @Override public MessageId getId() { return messageId; @@ -49,7 +47,7 @@ public class PropertyStoreMessage implements Message, Serializable { public Source getSource() { return source; } - + public PropertyStore getStore() { return store; } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringId.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringId.java index a584dadfec1..797d3a773ec 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringId.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringId.java @@ -18,14 +18,14 @@ import java.io.Serializable; public abstract class StringId implements Serializable { private static final long serialVersionUID = 80655792810954088L; - private Namespace namespace; - private Name name; + private final Namespace namespace; + private final Name name; public StringId(Namespace namespace, Name name) { this.namespace = namespace; this.name = name; } - + @Override public String toString() { return String.format("StringId (NameSpace: %s, Name: %s)", namespace.toString(), name.toString()); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringName.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringName.java index 1e6940d1fb2..cd994a1bce4 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringName.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringName.java @@ -17,12 +17,12 @@ import java.io.Serializable; */ public class StringName implements Name, Serializable { private static final long serialVersionUID = -7215226960243262972L; - private String name; + private final String name; public StringName(String name) { this.name = name; } - + @Override public String toString() { return name; diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringNamespace.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringNamespace.java index 5e46045f957..c345239d94e 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringNamespace.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/id/StringNamespace.java @@ -17,12 +17,12 @@ import java.io.Serializable; */ public class StringNamespace implements Namespace, Serializable { private static final long serialVersionUID = -8903438134102328929L; - private String namespace; + private final String namespace; public StringNamespace(String namespace) { this.namespace = namespace; } - + @Override public String toString() { return namespace; diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/Activator.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/Activator.java index f9ed1c01d22..b51d5f13aed 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/Activator.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/Activator.java @@ -35,24 +35,28 @@ public class Activator implements BundleActivator { private MessagingGatewayImpl messaging; private ServiceRegistration msgCommandProvider; - - + @Override public void start(BundleContext context) throws Exception { this.context = context; me = this; - serviceLookupAndRegistrarLifeCycle = new ServiceLookupAndRegistrarLifeCycle(context, ExportClassLoader.getInstance()); + serviceLookupAndRegistrarLifeCycle = + new ServiceLookupAndRegistrarLifeCycle(context, ExportClassLoader.getInstance()); serviceLookupAndRegistrarLifeCycle.open(true); - + messageServiceProviderImpl = new MessageServiceProviderImpl(ExportClassLoader.getInstance()); messageServiceProviderImpl.start(); - msgServiceRegistration = context.registerService(MessageService.class.getName(), messageServiceProviderImpl.getMessageService(), null); + msgServiceRegistration = + context.registerService(MessageService.class.getName(), messageServiceProviderImpl.getMessageService(), null); - msgCommandProvider = context.registerService(CommandProvider.class.getName(), new MessageServiceConsole(messageServiceProviderImpl.getMessageService()), null); + msgCommandProvider = + context.registerService(CommandProvider.class.getName(), + new MessageServiceConsole(messageServiceProviderImpl.getMessageService()), null); //old messaging = new MessagingGatewayImpl(); registration = context.registerService(MessagingGateway.class.getName(), messaging, null); } + @Override public void stop(BundleContext context) throws Exception { me = null; this.context = null; diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/FailoverConnectionNode.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/FailoverConnectionNode.java index 0fb552264fd..c6131dd54d4 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/FailoverConnectionNode.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/FailoverConnectionNode.java @@ -17,9 +17,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; - import javax.jms.JMSException; - import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.messaging.ConnectionListener; @@ -32,19 +30,19 @@ import org.eclipse.osee.framework.messaging.internal.activemq.OseeExceptionListe import org.eclipse.osee.framework.messaging.services.internal.OseeMessagingStatusImpl; /** - * @author Andrew M. Finkbeiner This is written using ActiveMQ as the use case. So it will only retry connection and it will keep - * all subscribes so that when a valid connection is made it will do all of the requested subscriptions. + * @author Andrew M. Finkbeiner This is written using ActiveMQ as the use case. So it will only retry connection and it + * will keep all subscribes so that when a valid connection is made it will do all of the requested subscriptions. */ public class FailoverConnectionNode implements ConnectionNode, Runnable { - private ConnectionNodeFailoverSupport connectionNode; - private List<SavedSubscribe> savedSubscribes; - private List<ConnectionListener> connectionListeners; - private ScheduledExecutorService scheduledExecutor; + private final ConnectionNodeFailoverSupport connectionNode; + private final List<SavedSubscribe> savedSubscribes; + private final List<ConnectionListener> connectionListeners; + private final ScheduledExecutorService scheduledExecutor; private boolean lastConnectedState = false; - private OseeExceptionListener exceptionListener; -private ScheduledFuture<?> itemToCancel; - + private final OseeExceptionListener exceptionListener; + private final ScheduledFuture<?> itemToCancel; + public FailoverConnectionNode(ConnectionNodeFailoverSupport connectionNode, ScheduledExecutorService scheduledExecutor, OseeExceptionListener exceptionListener) { this.connectionNode = connectionNode; this.exceptionListener = exceptionListener; @@ -57,40 +55,39 @@ private ScheduledFuture<?> itemToCancel; @Override public void send(MessageID messageId, Object message, OseeMessagingStatusCallback statusCallback) throws OseeCoreException { - send(messageId, message, null, statusCallback); + send(messageId, message, null, statusCallback); } - @Override public void send(MessageID messageId, Object message, Properties properties, OseeMessagingStatusCallback statusCallback) throws OseeCoreException { attemptSmartConnect(); - if(lastConnectedState){ - try{ - connectionNode.send(messageId, message, properties, statusCallback); - } catch (OseeCoreException ex){ - stop(); - run(); - connectionNode.send(messageId, message, properties, statusCallback); - } + if (lastConnectedState) { + try { + connectionNode.send(messageId, message, properties, statusCallback); + } catch (OseeCoreException ex) { + stop(); + run(); + connectionNode.send(messageId, message, properties, statusCallback); + } } } - + @Override public void send(MessageID messageId, Object message) throws OseeCoreException { String errorMessage = String.format("Error sending message(%s)", messageId.getId()); OseeMessagingStatusImpl defaultErrorHandler = new OseeMessagingStatusImpl(errorMessage, getClass()); this.send(messageId, message, defaultErrorHandler); } - + private void attemptSmartConnect() { - if(!lastConnectedState){ + if (!lastConnectedState) { run(); } } @Override public void stop() { - itemToCancel.cancel(false); + itemToCancel.cancel(false); connectionNode.stop(); } @@ -107,27 +104,26 @@ private ScheduledFuture<?> itemToCancel; attemptSmartConnect(); connectionNode.subscribe(messageId, listener, selector, statusCallback); } - + @Override public void subscribe(MessageID messageId, OseeMessagingListener listener) { String errorMessage = String.format("Error subscribing message(%s)", messageId.getId()); OseeMessagingStatusImpl defaultErrorHandler = new OseeMessagingStatusImpl(errorMessage, getClass()); this.subscribe(messageId, listener, defaultErrorHandler); } - + @Override public boolean subscribeToReply(MessageID messageId, OseeMessagingListener listener) { return connectionNode.subscribeToReply(messageId, listener); } - @Override public void unsubscribe(MessageID messageId, OseeMessagingListener listener) { String errorMessage = String.format("Error unsubscribing message(%s)", messageId.getId()); OseeMessagingStatusImpl defaultErrorHandler = new OseeMessagingStatusImpl(errorMessage, getClass()); this.unsubscribe(messageId, listener, defaultErrorHandler); } - + @Override public void unsubscribe(MessageID messageId, OseeMessagingListener listener, OseeMessagingStatusCallback statusCallback) { savedSubscribes.remove(new SavedSubscribe(messageId, listener, statusCallback)); @@ -140,6 +136,7 @@ private ScheduledFuture<?> itemToCancel; return false; } + @Override public void addConnectionListener(ConnectionListener connectionListener) { connectionListeners.add(connectionListener); if (lastConnectedState) { @@ -149,16 +146,18 @@ private ScheduledFuture<?> itemToCancel; } } + @Override public void removeConnectionListener(ConnectionListener connectionListener) { connectionListeners.remove(connectionListener); } private void subscribeToMessages() { for (SavedSubscribe subscribe : savedSubscribes) { - if(subscribe.selector == null){ + if (subscribe.selector == null) { connectionNode.subscribe(subscribe.messageId, subscribe.listener, subscribe.statusCallback); } else { - connectionNode.subscribe(subscribe.messageId, subscribe.listener, subscribe.selector, subscribe.statusCallback); + connectionNode.subscribe(subscribe.messageId, subscribe.listener, subscribe.selector, + subscribe.statusCallback); } } } @@ -181,34 +180,54 @@ private ScheduledFuture<?> itemToCancel; this.listener = listener; this.statusCallback = statusCallback; } - + @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + getOuterType().hashCode(); - result = prime * result + ((listener == null) ? 0 : listener.hashCode()); - result = prime * result + ((messageId == null) ? 0 : messageId.hashCode()); - result = prime * result + ((statusCallback == null) ? 0 : statusCallback.hashCode()); + result = prime * result + (listener == null ? 0 : listener.hashCode()); + result = prime * result + (messageId == null ? 0 : messageId.hashCode()); + result = prime * result + (statusCallback == null ? 0 : statusCallback.hashCode()); return result; } @Override public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } SavedSubscribe other = (SavedSubscribe) obj; - if (!getOuterType().equals(other.getOuterType())) return false; + if (!getOuterType().equals(other.getOuterType())) { + return false; + } if (listener == null) { - if (other.listener != null) return false; - } else if (!listener.equals(other.listener)) return false; + if (other.listener != null) { + return false; + } + } else if (!listener.equals(other.listener)) { + return false; + } if (messageId == null) { - if (other.messageId != null) return false; - } else if (!messageId.equals(other.messageId)) return false; + if (other.messageId != null) { + return false; + } + } else if (!messageId.equals(other.messageId)) { + return false; + } if (statusCallback == null) { - if (other.statusCallback != null) return false; - } else if (!statusCallback.equals(other.statusCallback)) return false; + if (other.statusCallback != null) { + return false; + } + } else if (!statusCallback.equals(other.statusCallback)) { + return false; + } return true; } @@ -226,22 +245,22 @@ private ScheduledFuture<?> itemToCancel; try { connectionNode.start(); subscribeToMessages(); - if(connectionNode.isConnected()){ + if (connectionNode.isConnected()) { connected(); } } catch (OseeCoreException ex) { OseeLog.log(FailoverConnectionNode.class, Level.FINE, ex); notConnected(); } - } + } } private synchronized void connected() { if (!lastConnectedState) { - lastConnectedState = true; + lastConnectedState = true; notifyConnectionListenersConnected(); } - + } private void notifyConnectionListenersConnected() { @@ -278,8 +297,8 @@ private ScheduledFuture<?> itemToCancel; return connectionNode.getSummary(); } - public void onException(JMSException ex) { - connectionNode.stop(); - run(); - } + public void onException(JMSException ex) { + connectionNode.stop(); + run(); + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/JAXBUtil.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/JAXBUtil.java index f3599890145..c1337469177 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/JAXBUtil.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/JAXBUtil.java @@ -14,42 +14,39 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; - import javax.xml.bind.JAXB; import javax.xml.transform.stream.StreamSource; - import org.eclipse.osee.framework.messaging.OseeMessagingListener; /** * @author Andrew M. Finkbeiner - * */ public class JAXBUtil { - public static void marshal(Object obj, OutputStream stream){ - JAXB.marshal(obj, stream); - } - - public static String marshal(Object obj) throws UnsupportedEncodingException{ - ByteArrayOutputStream os = new ByteArrayOutputStream(); - marshal(obj, os); - return new String(os.toByteArray(), "UTF-8"); - } - - public static Object unmarshal(String str, Class<?> clazz) throws UnsupportedEncodingException{ - ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes("UTF-8")); - return JAXB.unmarshal(new StreamSource(is), clazz); - } - - public static Object unmarshal(Object body, OseeMessagingListener listener) throws UnsupportedEncodingException{ - Class<?> pojoType = listener.getClazz(); - Object messageBody; - if (pojoType == null) { - messageBody = body; - } else { - messageBody = JAXBUtil.unmarshal(body.toString(), pojoType); - } - return messageBody; - } - + public static void marshal(Object obj, OutputStream stream) { + JAXB.marshal(obj, stream); + } + + public static String marshal(Object obj) throws UnsupportedEncodingException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + marshal(obj, os); + return new String(os.toByteArray(), "UTF-8"); + } + + public static Object unmarshal(String str, Class<?> clazz) throws UnsupportedEncodingException { + ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes("UTF-8")); + return JAXB.unmarshal(new StreamSource(is), clazz); + } + + public static Object unmarshal(Object body, OseeMessagingListener listener) throws UnsupportedEncodingException { + Class<?> pojoType = listener.getClazz(); + Object messageBody; + if (pojoType == null) { + messageBody = body; + } else { + messageBody = JAXBUtil.unmarshal(body.toString(), pojoType); + } + return messageBody; + } + } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceConsole.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceConsole.java index cec54b89263..540891c5bd4 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceConsole.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceConsole.java @@ -21,7 +21,7 @@ import org.eclipse.osgi.framework.console.CommandProvider; */ public class MessageServiceConsole implements CommandProvider { - private MessageService messageService; + private final MessageService messageService; MessageServiceConsole(MessageService messageService) { this.messageService = messageService; diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceImpl.java index ce756e8cd9d..fdad70e985d 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceImpl.java @@ -29,7 +29,7 @@ import org.eclipse.osee.framework.messaging.NodeInfo; */ public class MessageServiceImpl implements MessageService { private static final String VM_URI = "vm://localhost?broker.persistent=false"; - + private final NodeInfo defaultNode; private final Map<NodeInfo, ConnectionNode> connectionNodes; private final ConnectionNodeFactory factory; @@ -39,57 +39,64 @@ public class MessageServiceImpl implements MessageService { this.factory = factory; defaultNode = new NodeInfo("osee-jms", getDefaultURI()); } - - private URI getDefaultURI() { - URI defaultURI = null; - String uri = System.getProperty("osee.broker.primary.uri"); - if (uri == null) { - uri = VM_URI; - } - try { - defaultURI = new URI(uri); - } catch (URISyntaxException ex) { - try { - defaultURI = new URI(VM_URI); - } catch (URISyntaxException ex1) { - OseeLog.log(MessageServiceImpl.class, Level.SEVERE, ex1); - } - } - OseeLog.log(Activator.class, Level.FINER, String.format("Default URI for message Service [%s]", defaultURI.toASCIIString())); - return defaultURI; - } - @Override - public ConnectionNode getDefault() throws OseeCoreException { - return get(defaultNode); - } - + private URI getDefaultURI() { + URI defaultURI = null; + String uri = System.getProperty("osee.broker.primary.uri"); + if (uri == null) { + uri = VM_URI; + } + try { + defaultURI = new URI(uri); + } catch (URISyntaxException ex) { + try { + defaultURI = new URI(VM_URI); + } catch (URISyntaxException ex1) { + OseeLog.log(MessageServiceImpl.class, Level.SEVERE, ex1); + } + } + OseeLog.log(Activator.class, Level.FINER, + String.format("Default URI for message Service [%s]", defaultURI.toASCIIString())); + return defaultURI; + } + + @Override + public ConnectionNode getDefault() throws OseeCoreException { + return get(defaultNode); + } + + @Override public Collection<NodeInfo> getAvailableConnections() { return new ArrayList<NodeInfo>(connectionNodes.keySet()); } + @Override public int size() { return connectionNodes.size(); } + @Override public boolean isEmpty() { return connectionNodes.isEmpty(); } + @Override public ConnectionNode get(NodeInfo nodeInfo) throws OseeCoreException { ConnectionNode node = connectionNodes.get(nodeInfo); if (node == null) { - OseeLog.log(Activator.class, Level.FINEST, String.format("going to create a new Connection Node for [%s]", nodeInfo.toString())); + OseeLog.log(Activator.class, Level.FINEST, + String.format("going to create a new Connection Node for [%s]", nodeInfo.toString())); node = factory.create(nodeInfo); - connectionNodes.put(nodeInfo, (ConnectionNode)node); - OseeLog.log(Activator.class, Level.FINE, String.format("Created a new Connection Node for [%s]", nodeInfo.toString())); + connectionNodes.put(nodeInfo, node); + OseeLog.log(Activator.class, Level.FINE, + String.format("Created a new Connection Node for [%s]", nodeInfo.toString())); } return node; } - void stop() { - for(ConnectionNode node:connectionNodes.values()){ - node.stop(); - } - } + void stop() { + for (ConnectionNode node : connectionNodes.values()) { + node.stop(); + } + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceProviderImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceProviderImpl.java index 642a5e62cd5..66166b9394c 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceProviderImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/MessageServiceProviderImpl.java @@ -24,16 +24,17 @@ public class MessageServiceProviderImpl implements MessageServiceProvider { private MessageServiceImpl messageService; private ExecutorService executor; - private ClassLoader contextClassLoader; + private final ClassLoader contextClassLoader; MessageServiceProviderImpl(ClassLoader contextClassLoader) { this.contextClassLoader = contextClassLoader; } public void start() throws Exception { -// Thread.currentThread().setContextClassLoader(contextClassLoader); + // Thread.currentThread().setContextClassLoader(contextClassLoader); executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - messageService = new MessageServiceImpl(new ConnectionNodeFactoryImpl("1.0", Integer.toString(hashCode()), executor)); + messageService = + new MessageServiceImpl(new ConnectionNodeFactoryImpl("1.0", Integer.toString(hashCode()), executor)); } public void stop() throws Exception { diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqMessageListenerWrapper.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqMessageListenerWrapper.java index d00a84024fd..2e39372888e 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqMessageListenerWrapper.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqMessageListenerWrapper.java @@ -30,44 +30,47 @@ import org.eclipse.osee.framework.messaging.internal.Activator; */ class ActiveMqMessageListenerWrapper implements MessageListener { - private OseeMessagingListener listener; - private MessageProducer producer; - private Session session; - private ActiveMqUtil activeMqUtil; - - ActiveMqMessageListenerWrapper(ActiveMqUtil activeMqUtil, MessageProducer producer, Session session, OseeMessagingListener listener){ + private final OseeMessagingListener listener; + private final MessageProducer producer; + private final Session session; + private final ActiveMqUtil activeMqUtil; + + ActiveMqMessageListenerWrapper(ActiveMqUtil activeMqUtil, MessageProducer producer, Session session, OseeMessagingListener listener) { this.producer = producer; this.session = session; this.listener = listener; this.activeMqUtil = activeMqUtil; } - public void onMessage(javax.jms.Message jmsMessage){ - try{ + @Override + public void onMessage(javax.jms.Message jmsMessage) { + try { Destination destReply = jmsMessage.getJMSReplyTo(); - if(destReply != null){ - ActiveMQDestination dest = (ActiveMQDestination)jmsMessage.getJMSDestination(); + if (destReply != null) { + ActiveMQDestination dest = (ActiveMQDestination) jmsMessage.getJMSDestination(); String correlationId = dest.getPhysicalName(); - ReplyConnectionActiveMqImpl replyConnectionActiveMqImpl = new ReplyConnectionActiveMqImpl(activeMqUtil, session, producer, destReply, correlationId); + ReplyConnectionActiveMqImpl replyConnectionActiveMqImpl = + new ReplyConnectionActiveMqImpl(activeMqUtil, session, producer, destReply, correlationId); process(jmsMessage, replyConnectionActiveMqImpl); } else { process(jmsMessage, new ReplyConnectionActiveMqImpl()); - } - } catch (JMSException ex){ + } + } catch (JMSException ex) { OseeLog.log(ActiveMqMessageListenerWrapper.class, Level.SEVERE, ex); } catch (OseeCoreException ex) { OseeLog.log(ActiveMqMessageListenerWrapper.class, Level.SEVERE, ex); } - } - - OseeMessagingListener getListener(){ - return listener; - } - - private void process(javax.jms.Message message, ReplyConnection replyConnection) throws JMSException, OseeCoreException{ - Map<String, Object> headers = new HashMap<String, Object>(); - listener.process(activeMqUtil.translateMessage(message, listener.getClazz()), headers, replyConnection); - OseeLog.log(Activator.class, Level.FINE, String.format("recieved message %s - %s", message.getJMSDestination().toString(), message.toString())); - } + } + + OseeMessagingListener getListener() { + return listener; + } + + private void process(javax.jms.Message message, ReplyConnection replyConnection) throws JMSException, OseeCoreException { + Map<String, Object> headers = new HashMap<String, Object>(); + listener.process(activeMqUtil.translateMessage(message, listener.getClazz()), headers, replyConnection); + OseeLog.log(Activator.class, Level.FINE, + String.format("recieved message %s - %s", message.getJMSDestination().toString(), message.toString())); + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqUtil.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqUtil.java index aff0e2a5e55..2e973ca7dbf 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqUtil.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ActiveMqUtil.java @@ -12,14 +12,12 @@ package org.eclipse.osee.framework.messaging.internal.activemq; import java.io.Serializable; import java.io.UnsupportedEncodingException; - import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.TextMessage; - import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.exception.OseeExceptions; import org.eclipse.osee.framework.messaging.internal.JAXBUtil; @@ -29,10 +27,10 @@ import org.eclipse.osee.framework.messaging.internal.JAXBUtil; */ class ActiveMqUtil { - ActiveMqUtil(){ - + ActiveMqUtil() { + } - + Object translateMessage(Message message, Class<?> clazz) throws OseeCoreException, JMSException { Object messageBody = message; if (message instanceof TextMessage) { @@ -46,17 +44,17 @@ class ActiveMqUtil { } else { messageBody = text; } - } else if(message instanceof BytesMessage){ - int length = (int)((BytesMessage)message).getBodyLength(); + } else if (message instanceof BytesMessage) { + int length = (int) ((BytesMessage) message).getBodyLength(); byte[] bytes = new byte[length]; - ((BytesMessage)message).readBytes(bytes); + ((BytesMessage) message).readBytes(bytes); messageBody = bytes; - } else if(message instanceof ObjectMessage){ - messageBody = ((ObjectMessage)message).getObject(); + } else if (message instanceof ObjectMessage) { + messageBody = ((ObjectMessage) message).getObject(); } return messageBody; } - + Message createMessage(Session session, Class<?> clazz, Object body) throws OseeCoreException, JMSException { body = tryToGetSerialized(clazz, body); if (body instanceof String) { @@ -65,13 +63,13 @@ class ActiveMqUtil { BytesMessage byteMessage = session.createBytesMessage(); byteMessage.writeBytes((byte[]) body); return byteMessage; - } else if (body instanceof Serializable){ - return session.createObjectMessage((Serializable)body); + } else if (body instanceof Serializable) { + return session.createObjectMessage((Serializable) body); } else { throw new OseeCoreException(String.format("Unsupported java type [%s]", body.getClass().getName())); } } - + private Object tryToGetSerialized(Class<?> clazz, Object body) throws OseeCoreException { if (clazz != null) { try { diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java index 7e51609cb2a..45abe25af8b 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java @@ -19,7 +19,6 @@ import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.logging.Level; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.ExceptionListener; @@ -31,7 +30,6 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TemporaryTopic; import javax.jms.Topic; - import org.apache.activemq.ActiveMQConnectionFactory; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.exception.OseeWrappedException; @@ -54,22 +52,22 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi // private String version; // private String sourceId; - private NodeInfo nodeInfo; + private final NodeInfo nodeInfo; // private ExecutorService executor; private Connection connection; private Session session; private TemporaryTopic temporaryTopic; private MessageConsumer replyToConsumer; - private Map<String, OseeMessagingListener> replyListeners; - private CompositeKeyHashMap<String, MessageConsumer, OseeMessagingListener> regularListeners; + private final Map<String, OseeMessagingListener> replyListeners; + private final CompositeKeyHashMap<String, MessageConsumer, OseeMessagingListener> regularListeners; private boolean started = false; - private ConcurrentHashMap<String, Topic> topicCache; - private ConcurrentHashMap<Topic, MessageProducer> messageProducerCache; + private final ConcurrentHashMap<String, Topic> topicCache; + private final ConcurrentHashMap<Topic, MessageProducer> messageProducerCache; private final ExceptionListener exceptionListener; private MessageProducer replyProducer; - private ActiveMqUtil activeMqUtil; + private final ActiveMqUtil activeMqUtil; public ConnectionNodeActiveMq(String version, String sourceId, NodeInfo nodeInfo, ExecutorService executor, ExceptionListener exceptionListener) { this.nodeInfo = nodeInfo; @@ -81,13 +79,16 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi replyListeners = new ConcurrentHashMap<String, OseeMessagingListener>(); } + @Override public synchronized void start() throws OseeCoreException { if (started) { return; } try { String uri = nodeInfo.getUri().toASCIIString(); - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(ActiveMQConnectionFactory.DEFAULT_USER, ActiveMQConnectionFactory.DEFAULT_PASSWORD, uri); + ActiveMQConnectionFactory factory = + new ActiveMQConnectionFactory(ActiveMQConnectionFactory.DEFAULT_USER, + ActiveMQConnectionFactory.DEFAULT_PASSWORD, uri); connection = factory.createConnection(); connection.setExceptionListener(exceptionListener); session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); @@ -108,23 +109,23 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi OseeMessagingStatusImpl defaultErrorHandler = new OseeMessagingStatusImpl(errorMessage, getClass()); this.send(topic, body, defaultErrorHandler); } - + @Override public synchronized void send(MessageID messageId, Object message, OseeMessagingStatusCallback statusCallback) throws OseeCoreException { send(messageId, message, null, statusCallback); } - + @Override public synchronized void send(MessageID messageId, Object message, Properties properties, OseeMessagingStatusCallback statusCallback) throws OseeCoreException { try { if (messageId.isTopic()) { - try{ + try { sendInternal(messageId, message, properties, statusCallback); - } catch (JMSException ex){ + } catch (JMSException ex) { removeProducerFromCache(messageId); sendInternal(messageId, message, properties, statusCallback); } - // OseeLog.log(Activator.class, Level.FINE, String.format("Sending message %s - %s", topic.getName(), topic.getGuid())); + // OseeLog.log(Activator.class, Level.FINE, String.format("Sending message %s - %s", topic.getName(), topic.getGuid())); statusCallback.success(); } } catch (JMSException ex) { @@ -135,41 +136,48 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi throw new OseeWrappedException(ex); } } - - private synchronized void sendInternal(MessageID messageId, Object message, Properties properties, OseeMessagingStatusCallback statusCallback) throws JMSException, OseeCoreException { - Topic destination = getOrCreateTopic(messageId); - MessageProducer producer = getOrCreateProducer(destination); - Message msg = activeMqUtil.createMessage(session, messageId.getSerializationClass(), message); - if (messageId.isReplyRequired()) { - msg.setJMSReplyTo(temporaryTopic); - } - if(properties != null){ - for(Entry<Object, Object> entry:properties.entrySet()){ - if(entry.getValue() instanceof Integer){ - msg.setIntProperty(entry.getKey().toString(), (Integer)entry.getValue()); - } if(entry.getValue() instanceof Boolean){ - msg.setBooleanProperty(entry.getKey().toString(), (Boolean)entry.getValue()); - } if(entry.getValue() instanceof Byte){ - msg.setByteProperty(entry.getKey().toString(), (Byte)entry.getValue()); - } if(entry.getValue() instanceof Double){ - msg.setDoubleProperty(entry.getKey().toString(), (Double)entry.getValue()); - } if(entry.getValue() instanceof Float){ - msg.setFloatProperty(entry.getKey().toString(), (Float)entry.getValue()); - } if(entry.getValue() instanceof Long){ - msg.setLongProperty(entry.getKey().toString(), (Long)entry.getValue()); - } if(entry.getValue() instanceof String){ - msg.setStringProperty(entry.getKey().toString(), (String)entry.getValue()); - } if(entry.getValue() instanceof Short){ - msg.setShortProperty(entry.getKey().toString(), (Short)entry.getValue()); + + private synchronized void sendInternal(MessageID messageId, Object message, Properties properties, OseeMessagingStatusCallback statusCallback) throws JMSException, OseeCoreException { + Topic destination = getOrCreateTopic(messageId); + MessageProducer producer = getOrCreateProducer(destination); + Message msg = activeMqUtil.createMessage(session, messageId.getSerializationClass(), message); + if (messageId.isReplyRequired()) { + msg.setJMSReplyTo(temporaryTopic); + } + if (properties != null) { + for (Entry<Object, Object> entry : properties.entrySet()) { + if (entry.getValue() instanceof Integer) { + msg.setIntProperty(entry.getKey().toString(), (Integer) entry.getValue()); + } + if (entry.getValue() instanceof Boolean) { + msg.setBooleanProperty(entry.getKey().toString(), (Boolean) entry.getValue()); + } + if (entry.getValue() instanceof Byte) { + msg.setByteProperty(entry.getKey().toString(), (Byte) entry.getValue()); + } + if (entry.getValue() instanceof Double) { + msg.setDoubleProperty(entry.getKey().toString(), (Double) entry.getValue()); + } + if (entry.getValue() instanceof Float) { + msg.setFloatProperty(entry.getKey().toString(), (Float) entry.getValue()); + } + if (entry.getValue() instanceof Long) { + msg.setLongProperty(entry.getKey().toString(), (Long) entry.getValue()); + } + if (entry.getValue() instanceof String) { + msg.setStringProperty(entry.getKey().toString(), (String) entry.getValue()); + } + if (entry.getValue() instanceof Short) { + msg.setShortProperty(entry.getKey().toString(), (Short) entry.getValue()); } else { - msg.setObjectProperty(entry.getKey().toString(), entry.getValue()); - } - } - } - producer.send(msg); -// OseeLog.log(Activator.class, Level.FINE, String.format("Sending message %s - %s", topic.getName(), topic.getGuid())); - statusCallback.success(); - } + msg.setObjectProperty(entry.getKey().toString(), entry.getValue()); + } + } + } + producer.send(msg); + // OseeLog.log(Activator.class, Level.FINE, String.format("Sending message %s - %s", topic.getName(), topic.getGuid())); + statusCallback.success(); + } @Override public synchronized void subscribe(MessageID messageId, OseeMessagingListener listener, OseeMessagingStatusCallback statusCallback) { @@ -178,7 +186,8 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi if (isConnectedThrow()) { destination = getOrCreateTopic(messageId); MessageConsumer consumer = session.createConsumer(destination); - consumer.setMessageListener(new ActiveMqMessageListenerWrapper(activeMqUtil, replyProducer, session, listener)); + consumer.setMessageListener(new ActiveMqMessageListenerWrapper(activeMqUtil, replyProducer, session, + listener)); regularListeners.put(messageId.getId(), consumer, listener); statusCallback.success(); } else { @@ -190,7 +199,7 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi statusCallback.fail(ex); } } - + @Override public void subscribe(MessageID messageId, OseeMessagingListener listener, String selector, OseeMessagingStatusCallback statusCallback) { Topic destination; @@ -198,7 +207,8 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi if (isConnectedThrow()) { destination = getOrCreateTopic(messageId); MessageConsumer consumer = session.createConsumer(destination, selector); - consumer.setMessageListener(new ActiveMqMessageListenerWrapper(activeMqUtil, replyProducer, session, listener)); + consumer.setMessageListener(new ActiveMqMessageListenerWrapper(activeMqUtil, replyProducer, session, + listener)); regularListeners.put(messageId.getId(), consumer, listener); statusCallback.success(); } else { @@ -210,7 +220,7 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi statusCallback.fail(ex); } } - + @Override public void subscribe(MessageID messageId, OseeMessagingListener listener) { String errorMessage = String.format("Error subscribing message(%s)", messageId.getId()); @@ -236,10 +246,10 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi } return producer; } - - private void removeProducerFromCache(MessageID topic) throws JMSException{ - Topic destination = getOrCreateTopic(topic); - messageProducerCache.remove(destination); + + private void removeProducerFromCache(MessageID topic) throws JMSException { + Topic destination = getOrCreateTopic(topic); + messageProducerCache.remove(destination); } @Override @@ -247,7 +257,7 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi replyListeners.put(messageId.getId(), listener); return true; } - + @Override public void unsubscribe(MessageID messageId, OseeMessagingListener listener) { String errorMessage = String.format("Error unsubscribing message(%s)", messageId.getId()); @@ -260,18 +270,18 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi Map<MessageConsumer, OseeMessagingListener> listeners = regularListeners.getKeyedValues(messageId.getId()); List<MessageConsumer> consumersToRemove = new ArrayList<MessageConsumer>(); if (listeners != null) { - try{ - for(Entry<MessageConsumer, OseeMessagingListener> entry:listeners.entrySet()){ - if(entry.getValue().equals(listener)){ + try { + for (Entry<MessageConsumer, OseeMessagingListener> entry : listeners.entrySet()) { + if (entry.getValue().equals(listener)) { entry.getKey().setMessageListener(null); consumersToRemove.add(entry.getKey()); } } - for(MessageConsumer messageConsumer: consumersToRemove){ - messageConsumer.setMessageListener(null); - messageConsumer.close(); + for (MessageConsumer messageConsumer : consumersToRemove) { + messageConsumer.setMessageListener(null); + messageConsumer.close(); } - }catch (JMSException ex) { + } catch (JMSException ex) { statusCallback.fail(ex); } } @@ -291,7 +301,8 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi if (correlationId != null) { OseeMessagingListener listener = replyListeners.get(correlationId); if (listener != null) { - listener.process(activeMqUtil.translateMessage(jmsMessage, listener.getClazz()), new HashMap<String, Object>(), new ReplyConnectionActiveMqImpl()); + listener.process(activeMqUtil.translateMessage(jmsMessage, listener.getClazz()), + new HashMap<String, Object>(), new ReplyConnectionActiveMqImpl()); } } } catch (JMSException ex) { @@ -304,9 +315,9 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi @Override public synchronized void stop() { - topicCache.clear(); - messageProducerCache.clear(); - regularListeners.clear(); + topicCache.clear(); + messageProducerCache.clear(); + regularListeners.clear(); try { if (session != null) { session.close(); @@ -351,12 +362,11 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi @Override public void removeConnectionListener(ConnectionListener connectionListener) { } - - + @Override public String getSenders() { StringBuilder sb = new StringBuilder(); - for(Entry<Topic, MessageProducer> entry:this.messageProducerCache.entrySet()){ + for (Entry<Topic, MessageProducer> entry : this.messageProducerCache.entrySet()) { try { sb.append(String.format("Topic [%s] \n", entry.getKey().getTopicName())); sb.append(String.format("\tProducer Destination [%s]\n", entry.getValue().getDestination().toString())); @@ -370,14 +380,14 @@ class ConnectionNodeActiveMq implements ConnectionNodeFailoverSupport, MessageLi @Override public String getSubscribers() { StringBuilder sb = new StringBuilder(); - for(Pair<String, MessageConsumer> entry:this.regularListeners.keySet()){ + for (Pair<String, MessageConsumer> entry : this.regularListeners.keySet()) { try { sb.append(String.format("Topic [%s] \n", entry.getFirst())); sb.append(String.format("\tConsumer Selector [%s]\n", entry.getSecond().getMessageSelector())); MessageListener listener = entry.getSecond().getMessageListener(); - if(listener instanceof ActiveMqMessageListenerWrapper){ - sb.append("\tConsumer Listeners:\n"); - sb.append(String.format("\t\t%s\n", ((ActiveMqMessageListenerWrapper)listener).getListener().toString())); + if (listener instanceof ActiveMqMessageListenerWrapper) { + sb.append("\tConsumer Listeners:\n"); + sb.append(String.format("\t\t%s\n", ((ActiveMqMessageListenerWrapper) listener).getListener().toString())); } } catch (JMSException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeFactoryImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeFactoryImpl.java index 21076789483..266cfa840c9 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeFactoryImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeFactoryImpl.java @@ -14,7 +14,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.logging.Level; - import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.messaging.ConnectionNode; @@ -42,8 +41,9 @@ public class ConnectionNodeFactoryImpl implements ConnectionNodeFactory { @Override public synchronized ConnectionNode create(NodeInfo nodeInfo) { - OseeExceptionListener exceptionListener = new OseeExceptionListener(); - final ConnectionNodeActiveMq node = new ConnectionNodeActiveMq(version, sourceId, nodeInfo, executor, exceptionListener); + OseeExceptionListener exceptionListener = new OseeExceptionListener(); + final ConnectionNodeActiveMq node = + new ConnectionNodeActiveMq(version, sourceId, nodeInfo, executor, exceptionListener); OseeLog.log(Activator.class, Level.FINEST, "Going to start a connection node."); try { node.start(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/OseeExceptionListener.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/OseeExceptionListener.java index bcc272644a8..80d64f1f17c 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/OseeExceptionListener.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/OseeExceptionListener.java @@ -12,26 +12,24 @@ package org.eclipse.osee.framework.messaging.internal.activemq; import javax.jms.ExceptionListener; import javax.jms.JMSException; - import org.eclipse.osee.framework.messaging.internal.FailoverConnectionNode; /** * @author Andrew M. Finkbeiner - * */ public class OseeExceptionListener implements ExceptionListener { - private FailoverConnectionNode failoverConnectionNode; + private FailoverConnectionNode failoverConnectionNode; - @Override - public void onException(JMSException ex) { - if(failoverConnectionNode != null){ - failoverConnectionNode.onException(ex); - } - } + @Override + public void onException(JMSException ex) { + if (failoverConnectionNode != null) { + failoverConnectionNode.onException(ex); + } + } - public void setListener(FailoverConnectionNode failoverConnectionNode) { - this.failoverConnectionNode = failoverConnectionNode; - } + public void setListener(FailoverConnectionNode failoverConnectionNode) { + this.failoverConnectionNode = failoverConnectionNode; + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ReplyConnectionActiveMqImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ReplyConnectionActiveMqImpl.java index f89f4550479..0332d2c4ae6 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ReplyConnectionActiveMqImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ReplyConnectionActiveMqImpl.java @@ -23,10 +23,8 @@ import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback; import org.eclipse.osee.framework.messaging.ReplyConnection; import org.eclipse.osee.framework.messaging.internal.Activator; - /** * @author Andrew M. Finkbeiner - * */ class ReplyConnectionActiveMqImpl implements ReplyConnection { @@ -36,7 +34,7 @@ class ReplyConnectionActiveMqImpl implements ReplyConnection { private String correlationId; private Session session; private ActiveMqUtil activeMqUtil; - + ReplyConnectionActiveMqImpl(ActiveMqUtil activeMqUtil, Session session, MessageProducer producer, Destination destReply, String correlationId) { isReplyRequested = true; this.producer = producer; diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/ConcurrentListMap.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/ConcurrentListMap.java index 0bcd2954599..b23bb87c40f 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/ConcurrentListMap.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/ConcurrentListMap.java @@ -21,8 +21,8 @@ import java.util.concurrent.CopyOnWriteArrayList; */ public class ConcurrentListMap<MAP_TYPE, LIST_TYPE> { - private Map<MAP_TYPE, List<LIST_TYPE>> data; - private List<LIST_TYPE> EMPTY_LIST = new ArrayList<LIST_TYPE>(); + private final Map<MAP_TYPE, List<LIST_TYPE>> data; + private final List<LIST_TYPE> EMPTY_LIST = new ArrayList<LIST_TYPE>(); public ConcurrentListMap() { data = new HashMap<MAP_TYPE, List<LIST_TYPE>>(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/EndpointSendCollection.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/EndpointSendCollection.java index 630edfa3661..6366dbe9e47 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/EndpointSendCollection.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/EndpointSendCollection.java @@ -27,8 +27,8 @@ import org.eclipse.osee.framework.messaging.id.ProtocolId; public class EndpointSendCollection { private final List<EndpointSend> endpoints; - private Map<ProtocolId, EndpointSend> protocolMapping; - private Map<MessageId, ProtocolId> messageIdMapping; + private final Map<ProtocolId, EndpointSend> protocolMapping; + private final Map<MessageId, ProtocolId> messageIdMapping; public EndpointSendCollection() { endpoints = new CopyOnWriteArrayList<EndpointSend>(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessageListenerCollection.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessageListenerCollection.java index 7009ad52dfc..fcd5d447a4f 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessageListenerCollection.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessageListenerCollection.java @@ -20,8 +20,8 @@ import org.eclipse.osee.framework.messaging.id.MessageId; */ public class MessageListenerCollection { - private ConcurrentListMap<MessageId, ReceiveListener> receiveListeners; - private ConcurrentListMap<MessageId, SendListener> sendListeners; + private final ConcurrentListMap<MessageId, ReceiveListener> receiveListeners; + private final ConcurrentListMap<MessageId, SendListener> sendListeners; public MessageListenerCollection() { receiveListeners = new ConcurrentListMap<MessageId, ReceiveListener>(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessagingGatewayImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessagingGatewayImpl.java index e6b9486aa15..b976cc8c3f7 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessagingGatewayImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/old/MessagingGatewayImpl.java @@ -26,9 +26,9 @@ import org.eclipse.osee.framework.messaging.id.ProtocolId; */ public class MessagingGatewayImpl implements MessagingGateway, ApplicationDistributer { - private MessageListenerCollection messageListeners; - private EndpointReceiveCollection endpointReceivers; - private EndpointSendCollection endpointSenders; + private final MessageListenerCollection messageListeners; + private final EndpointReceiveCollection endpointReceivers; + private final EndpointSendCollection endpointSenders; public MessagingGatewayImpl() { messageListeners = new MessageListenerCollection(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/BaseMessages.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/BaseMessages.java index 0a22a46914f..75b83218f3d 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/BaseMessages.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/BaseMessages.java @@ -17,46 +17,45 @@ import org.eclipse.osee.framework.messaging.services.messages.Synch; /** * @author Andrew M. Finkbeiner - * */ public enum BaseMessages implements MessageID { - ServiceHealth(true, "ABjyjamBQRvvAGcWpRQA", "osee.message.core.ServiceHealth", ServiceHealth.class, false), - ServiceHealthRequest(true, "ABkAHOSFQ3VUZcfzsAgA", "osee.message.core.ServiceHealthRequest", ServiceHealthRequest.class, true), - Synch(true, "ABkweOSFQ3yuZcfzsAgA", "osee.message.core.ServiceHealthRequest", Synch.class, true); - - private String name; - private Class<?> clazz; - boolean isReplyRequired; + ServiceHealth(true, "ABjyjamBQRvvAGcWpRQA", "osee.message.core.ServiceHealth", ServiceHealth.class, false), + ServiceHealthRequest(true, "ABkAHOSFQ3VUZcfzsAgA", "osee.message.core.ServiceHealthRequest", ServiceHealthRequest.class, true), + Synch(true, "ABkweOSFQ3yuZcfzsAgA", "osee.message.core.ServiceHealthRequest", Synch.class, true); + + private String name; + private Class<?> clazz; + boolean isReplyRequired; private boolean isTopic; private String guid; - - BaseMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired){ - this.guid = guid; - this.name = name; - this.clazz = clazz; - this.isReplyRequired = isReplyRequired; - this.isTopic = isTopic; - } - - @Override - public String getName() { - return name; - } - @Override - public Class<?> getSerializationClass() { - return clazz; - } + BaseMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired) { + this.guid = guid; + this.name = name; + this.clazz = clazz; + this.isReplyRequired = isReplyRequired; + this.isTopic = isTopic; + } - @Override - public boolean isReplyRequired() { - return isReplyRequired; - } + @Override + public String getName() { + return name; + } - @Override - public boolean isTopic(){ - return isTopic; - } + @Override + public Class<?> getSerializationClass() { + return clazz; + } + + @Override + public boolean isReplyRequired() { + return isReplyRequired; + } + + @Override + public boolean isTopic() { + return isTopic; + } @Override public String getId() { diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RegisteredServiceReference.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RegisteredServiceReference.java index 673be47ee7f..320d9e27e42 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RegisteredServiceReference.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RegisteredServiceReference.java @@ -12,7 +12,6 @@ package org.eclipse.osee.framework.messaging.services; /** * @author Andrew M. Finkbeiner - * */ public interface RegisteredServiceReference { void update(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceLookup.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceLookup.java index 12a514b6ba7..e063669211d 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceLookup.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceLookup.java @@ -12,12 +12,15 @@ package org.eclipse.osee.framework.messaging.services; /** * @author Andrew M. Finkbeiner - * */ public interface RemoteServiceLookup { - void start(); - void stop(); - void sendOutRequestsForServiceHealth(); - void register(String serviceId, String serviceVersion, ServiceNotification notification); - boolean unregister(String serviceId, String serviceVersion, ServiceNotification notification); + void start(); + + void stop(); + + void sendOutRequestsForServiceHealth(); + + void register(String serviceId, String serviceVersion, ServiceNotification notification); + + boolean unregister(String serviceId, String serviceVersion, ServiceNotification notification); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceRegistrar.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceRegistrar.java index d0852d7b2b3..53c6b702726 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceRegistrar.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/RemoteServiceRegistrar.java @@ -14,11 +14,13 @@ import java.net.URI; /** * @author Andrew M. Finkbeiner - * */ public interface RemoteServiceRegistrar { - void start(); - void stop(); - RegisteredServiceReference registerService(String serviceName, String serviceVersion, String serviceUniqueId, URI broker, ServiceInfoPopulator infoPopulator, int refreshRateInSeconds); - boolean unregisterService(String serviceName, String serviceVersion, String serviceUniqueId); + void start(); + + void stop(); + + RegisteredServiceReference registerService(String serviceName, String serviceVersion, String serviceUniqueId, URI broker, ServiceInfoPopulator infoPopulator, int refreshRateInSeconds); + + boolean unregisterService(String serviceName, String serviceVersion, String serviceUniqueId); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceInfoPopulator.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceInfoPopulator.java index cbf1b0788ee..5371b19dc1f 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceInfoPopulator.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceInfoPopulator.java @@ -11,13 +11,11 @@ package org.eclipse.osee.framework.messaging.services; import java.util.List; - import org.eclipse.osee.framework.messaging.services.messages.ServiceDescriptionPair; /** * @author Andrew M. Finkbeiner - * */ public interface ServiceInfoPopulator { - void updateServiceInfo(List<ServiceDescriptionPair> serviceDescription); + void updateServiceInfo(List<ServiceDescriptionPair> serviceDescription); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceNotification.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceNotification.java index b1e182aecae..a18677a118d 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceNotification.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/ServiceNotification.java @@ -14,9 +14,9 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealth; /** * @author Andrew M. Finkbeiner - * */ public interface ServiceNotification { - void onServiceUpdate(ServiceHealth serviceHealth); - void onServiceGone(ServiceHealth serviceHealth); + void onServiceUpdate(ServiceHealth serviceHealth); + + void onServiceGone(ServiceHealth serviceHealth); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthRequestListener.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthRequestListener.java index b6eb362f0b7..fee47f27e60 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthRequestListener.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthRequestListener.java @@ -12,7 +12,6 @@ package org.eclipse.osee.framework.messaging.services.internal; import java.util.List; import java.util.Map; - import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.messaging.OseeMessagingListener; import org.eclipse.osee.framework.messaging.ReplyConnection; @@ -20,31 +19,28 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealthReque /** * @author Andrew M. Finkbeiner - * */ public class HealthRequestListener extends OseeMessagingListener { - private CompositeKeyHashMap<String, String, List<UpdateStatus>> mapForReplys; + private final CompositeKeyHashMap<String, String, List<UpdateStatus>> mapForReplys; - public HealthRequestListener( - CompositeKeyHashMap<String, String, List<UpdateStatus>> mapForReplys) { - super(ServiceHealthRequest.class); - this.mapForReplys = mapForReplys; - } + public HealthRequestListener(CompositeKeyHashMap<String, String, List<UpdateStatus>> mapForReplys) { + super(ServiceHealthRequest.class); + this.mapForReplys = mapForReplys; + } - @Override - public void process(Object message, Map<String, Object> headers, - ReplyConnection replyConnection) { - if (replyConnection.isReplyRequested()) { - ServiceHealthRequest request = (ServiceHealthRequest)message; - List<UpdateStatus> updates = mapForReplys.get(request.getServiceName(), request.getServiceVersion()); - if(updates != null){ - for(UpdateStatus update:updates){ - if(update != null){ - update.run(); - } - } - } - } - } + @Override + public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) { + if (replyConnection.isReplyRequested()) { + ServiceHealthRequest request = (ServiceHealthRequest) message; + List<UpdateStatus> updates = mapForReplys.get(request.getServiceName(), request.getServiceVersion()); + if (updates != null) { + for (UpdateStatus update : updates) { + if (update != null) { + update.run(); + } + } + } + } + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthServiceListener.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthServiceListener.java index 79210799740..de7a9c8449d 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthServiceListener.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/HealthServiceListener.java @@ -21,49 +21,48 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealth; /** * @author Andrew M. Finkbeiner - * */ class HealthServiceListener extends OseeMessagingListener { - private static final int WIGGLE_ROOM = 20000; - - private CompositeKeyHashMap<String/* serviceName */, String /* serviceVersion */, Map<String /* serviceUniqueId */,ServiceHealthPlusTimeout>> map; - private CompositeKeyHashMap<String/* serviceName */, String /* serviceVersion */, List<ServiceNotification>> callbacks; - - HealthServiceListener(CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map, CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks){ - super(ServiceHealth.class); - this.map = map; - this.callbacks = callbacks; - } - - @Override - public void process(Object message, Map<String, Object> headers, - ReplyConnection replyConnection) { - ServiceHealth health = (ServiceHealth)message; - - if(health.isStopping()){ - List<ServiceNotification> itemsToNotify = callbacks.get(health.getServiceName(), health.getServiceVersion()); - if(itemsToNotify != null){ - for(ServiceNotification notification :itemsToNotify){ + private static final int WIGGLE_ROOM = 20000; + + private final CompositeKeyHashMap<String/* serviceName */, String /* serviceVersion */, Map<String /* serviceUniqueId */, ServiceHealthPlusTimeout>> map; + private final CompositeKeyHashMap<String/* serviceName */, String /* serviceVersion */, List<ServiceNotification>> callbacks; + + HealthServiceListener(CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map, CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks) { + super(ServiceHealth.class); + this.map = map; + this.callbacks = callbacks; + } + + @Override + public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) { + ServiceHealth health = (ServiceHealth) message; + + if (health.isStopping()) { + List<ServiceNotification> itemsToNotify = callbacks.get(health.getServiceName(), health.getServiceVersion()); + if (itemsToNotify != null) { + for (ServiceNotification notification : itemsToNotify) { notification.onServiceGone(health); } } - } else { - Map<String, ServiceHealthPlusTimeout> idMap = map.get(health.getServiceName(), health.getServiceVersion()); - if(idMap == null){ - idMap = new ConcurrentHashMap<String, ServiceHealthPlusTimeout>(); - map.put(health.getServiceName(), health.getServiceVersion(), idMap); - } - long shouldHaveRenewedTime = System.currentTimeMillis() + (health.getRefreshRateInSeconds()*1000) + WIGGLE_ROOM; - idMap.put(health.getServiceUniqueId(), new ServiceHealthPlusTimeout(health, shouldHaveRenewedTime)); - - List<ServiceNotification> itemsToNotify = callbacks.get(health.getServiceName(), health.getServiceVersion()); - if(itemsToNotify != null){ - for(ServiceNotification notification :itemsToNotify){ - notification.onServiceUpdate(health); - } - } - } - } + } else { + Map<String, ServiceHealthPlusTimeout> idMap = map.get(health.getServiceName(), health.getServiceVersion()); + if (idMap == null) { + idMap = new ConcurrentHashMap<String, ServiceHealthPlusTimeout>(); + map.put(health.getServiceName(), health.getServiceVersion(), idMap); + } + long shouldHaveRenewedTime = + System.currentTimeMillis() + health.getRefreshRateInSeconds() * 1000 + WIGGLE_ROOM; + idMap.put(health.getServiceUniqueId(), new ServiceHealthPlusTimeout(health, shouldHaveRenewedTime)); + + List<ServiceNotification> itemsToNotify = callbacks.get(health.getServiceName(), health.getServiceVersion()); + if (itemsToNotify != null) { + for (ServiceNotification notification : itemsToNotify) { + notification.onServiceUpdate(health); + } + } + } + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/MonitorTimedOutServices.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/MonitorTimedOutServices.java index ca59a9ea4bc..599fb598428 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/MonitorTimedOutServices.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/MonitorTimedOutServices.java @@ -13,66 +13,64 @@ package org.eclipse.osee.framework.messaging.services.internal; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.jdk.core.type.Pair; import org.eclipse.osee.framework.messaging.services.ServiceNotification; /** * @author Andrew M. Finkbeiner - * */ class MonitorTimedOutServices implements Runnable { - private CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map; - private CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks; - - public MonitorTimedOutServices( - CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map, CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks) { - this.map = map; - this.callbacks = callbacks; - } + private final CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map; + private final CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks; + + public MonitorTimedOutServices(CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map, CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks) { + this.map = map; + this.callbacks = callbacks; + } + + @Override + public void run() { + List<ThreeItems> toRemove = new ArrayList<ThreeItems>(); + long currentSystemTime = System.currentTimeMillis(); + Set<Pair<String, String>> keySet = map.keySet(); + for (Pair<String, String> pair : keySet) { + Map<String, ServiceHealthPlusTimeout> items = map.get(pair.getFirst(), pair.getSecond()); + for (Entry<String, ServiceHealthPlusTimeout> key : items.entrySet()) { + if (key.getValue().isTimedOut(currentSystemTime)) { + toRemove.add(new ThreeItems(pair.getFirst(), pair.getSecond(), key.getKey())); + List<ServiceNotification> list = callbacks.get(pair.getFirst(), pair.getSecond()); + for (ServiceNotification notify : list) { + notify.onServiceGone(key.getValue().getServiceHealth()); + } + } + } + } + for (ThreeItems item : toRemove) { + Map<String, ServiceHealthPlusTimeout> innerMap = map.get(item.first, item.second); + innerMap.remove(item.key); + System.out.println(item.key); + if (innerMap.isEmpty()) { + map.remove(item.first, item.second); + System.out.println("removed " + item.first + item.second); + } + } + } + + private static class ThreeItems { - @Override - public void run() { - List<ThreeItems> toRemove = new ArrayList<ThreeItems>(); - long currentSystemTime = System.currentTimeMillis(); - Set<Pair<String, String>> keySet = map.keySet(); - for(Pair<String, String> pair:keySet){ - Map<String, ServiceHealthPlusTimeout> items = map.get(pair.getFirst(), pair.getSecond()); - for(Entry<String, ServiceHealthPlusTimeout> key:items.entrySet()){ - if(key.getValue().isTimedOut(currentSystemTime)){ - toRemove.add(new ThreeItems(pair.getFirst(), pair.getSecond(), key.getKey())); - List<ServiceNotification> list = callbacks.get(pair.getFirst(), pair.getSecond()); - for(ServiceNotification notify:list){ - notify.onServiceGone(key.getValue().getServiceHealth()); - } - } - } - } - for(ThreeItems item:toRemove){ - Map<String, ServiceHealthPlusTimeout> innerMap = map.get(item.first, item.second); - innerMap.remove(item.key); - System.out.println(item.key); - if(innerMap.isEmpty()){ - map.remove(item.first, item.second); - System.out.println("removed " + item.first + item.second); - } - } - } + String first; + String second; + String key; - private static class ThreeItems { - - String first; - String second; - String key; - - ThreeItems(String first, String second, String key){ - this.first = first; - this.second = second; - this.key = key; - } - } + ThreeItems(String first, String second, String key) { + this.first = first; + this.second = second; + this.key = key; + } + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/OseeMessagingStatusImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/OseeMessagingStatusImpl.java index 6effedf9fb8..0e6763932ea 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/OseeMessagingStatusImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/OseeMessagingStatusImpl.java @@ -11,32 +11,30 @@ package org.eclipse.osee.framework.messaging.services.internal; import java.util.logging.Level; - import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback; /** * @author Andrew M. Finkbeiner - * */ public class OseeMessagingStatusImpl implements OseeMessagingStatusCallback { - private String failureMessage; - private Class<?> clazz; - - public OseeMessagingStatusImpl(String failureMessage, Class<?> clazz){ - this.failureMessage = failureMessage; - this.clazz = clazz; - } - - @Override - public void fail(Throwable th) { - th.printStackTrace(); - OseeLog.log(clazz, Level.SEVERE, failureMessage, th); - } + private final String failureMessage; + private final Class<?> clazz; + + public OseeMessagingStatusImpl(String failureMessage, Class<?> clazz) { + this.failureMessage = failureMessage; + this.clazz = clazz; + } + + @Override + public void fail(Throwable th) { + th.printStackTrace(); + OseeLog.log(clazz, Level.SEVERE, failureMessage, th); + } - @Override - public void success() { - } + @Override + public void success() { + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceLookupImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceLookupImpl.java index b4143c422c0..3abb886ba71 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceLookupImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceLookupImpl.java @@ -29,100 +29,93 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealthReque /** * @author Andrew M. Finkbeiner - * */ public class RemoteServiceLookupImpl implements RemoteServiceLookup { - private ConnectionNode connectionNode; - private CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map; - private CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks; - private HealthServiceListener healthServiceListener; + private final ConnectionNode connectionNode; + private final CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>> map; + private final CompositeKeyHashMap<String, String, List<ServiceNotification>> callbacks; + private final HealthServiceListener healthServiceListener; public RemoteServiceLookupImpl(ConnectionNode node, ScheduledExecutorService executor) { - this.connectionNode = node; - map = new CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>>(25, true); - callbacks = new CompositeKeyHashMap<String, String, List<ServiceNotification>>( - 25, true); - healthServiceListener = new HealthServiceListener(map, callbacks); - connectionNode.subscribeToReply(BaseMessages.ServiceHealthRequest, - healthServiceListener); - executor.scheduleAtFixedRate(new MonitorTimedOutServices(map, callbacks), 30, 30, TimeUnit.SECONDS); - } - - public void start(){ - connectionNode.subscribe(BaseMessages.ServiceHealth, - healthServiceListener, - new OseeMessagingStatusImpl("Failed to subscribe to " + BaseMessages.ServiceHealth.getName(), - RemoteServiceLookupImpl.class)); - - } - - public void stop(){ - connectionNode.unsubscribe(BaseMessages.ServiceHealth, - healthServiceListener, - new OseeMessagingStatusImpl("Failed to subscribe to " + BaseMessages.ServiceHealth.getName(), - RemoteServiceLookupImpl.class)); - } - + this.connectionNode = node; + map = new CompositeKeyHashMap<String, String, Map<String, ServiceHealthPlusTimeout>>(25, true); + callbacks = new CompositeKeyHashMap<String, String, List<ServiceNotification>>(25, true); + healthServiceListener = new HealthServiceListener(map, callbacks); + connectionNode.subscribeToReply(BaseMessages.ServiceHealthRequest, healthServiceListener); + executor.scheduleAtFixedRate(new MonitorTimedOutServices(map, callbacks), 30, 30, TimeUnit.SECONDS); + } - @Override - public void register(String serviceName, String serviceVersion, - ServiceNotification notification) { - addListener(serviceName, serviceVersion, notification); - Map<String, ServiceHealthPlusTimeout> healthMap = map.get(serviceName, serviceVersion); - if (healthMap != null) { - for(ServiceHealthPlusTimeout serviceHealth:healthMap.values()){ - notification.onServiceUpdate(serviceHealth.getServiceHealth()); - } - } else { - sendOutRequest(serviceName, serviceVersion); - } - } - - public void sendOutRequestsForServiceHealth(){ - Set<Pair<String, String>> pairs = callbacks.keySet(); - for(Pair<String, String> pair:pairs){ - sendOutRequest(pair.getFirst(), pair.getSecond()); - } - } - - private void sendOutRequest(String serviceName, String serviceVersion){ - ServiceHealthRequest request = new ServiceHealthRequest(); + @Override + public void start() { + connectionNode.subscribe(BaseMessages.ServiceHealth, healthServiceListener, new OseeMessagingStatusImpl( + "Failed to subscribe to " + BaseMessages.ServiceHealth.getName(), RemoteServiceLookupImpl.class)); + + } + + @Override + public void stop() { + connectionNode.unsubscribe(BaseMessages.ServiceHealth, healthServiceListener, new OseeMessagingStatusImpl( + "Failed to subscribe to " + BaseMessages.ServiceHealth.getName(), RemoteServiceLookupImpl.class)); + } + + @Override + public void register(String serviceName, String serviceVersion, ServiceNotification notification) { + addListener(serviceName, serviceVersion, notification); + Map<String, ServiceHealthPlusTimeout> healthMap = map.get(serviceName, serviceVersion); + if (healthMap != null) { + for (ServiceHealthPlusTimeout serviceHealth : healthMap.values()) { + notification.onServiceUpdate(serviceHealth.getServiceHealth()); + } + } else { + sendOutRequest(serviceName, serviceVersion); + } + } + + @Override + public void sendOutRequestsForServiceHealth() { + Set<Pair<String, String>> pairs = callbacks.keySet(); + for (Pair<String, String> pair : pairs) { + sendOutRequest(pair.getFirst(), pair.getSecond()); + } + } + + private void sendOutRequest(String serviceName, String serviceVersion) { + ServiceHealthRequest request = new ServiceHealthRequest(); request.setServiceName(serviceName); request.setServiceVersion(serviceVersion); try { - connectionNode.send(BaseMessages.ServiceHealthRequest, request, new OseeMessagingStatusImpl(String.format("Failed to send Health Request for %s [%s]", serviceName, serviceVersion), RemoteServiceLookup.class)); + connectionNode.send( + BaseMessages.ServiceHealthRequest, + request, + new OseeMessagingStatusImpl(String.format("Failed to send Health Request for %s [%s]", serviceName, + serviceVersion), RemoteServiceLookup.class)); } catch (OseeCoreException ex) { OseeLog.log(RemoteServiceLookupImpl.class, Level.SEVERE, ex); } - } + } - private void addListener(String serviceName, String serviceVersion, - ServiceNotification notification) { - List<ServiceNotification> itemsToNotify = callbacks.get(serviceName, - serviceVersion); - if (itemsToNotify == null) { - itemsToNotify = new CopyOnWriteArrayList<ServiceNotification>(); - callbacks.put(serviceName, serviceVersion, itemsToNotify); - } - itemsToNotify.add(notification); - } + private void addListener(String serviceName, String serviceVersion, ServiceNotification notification) { + List<ServiceNotification> itemsToNotify = callbacks.get(serviceName, serviceVersion); + if (itemsToNotify == null) { + itemsToNotify = new CopyOnWriteArrayList<ServiceNotification>(); + callbacks.put(serviceName, serviceVersion, itemsToNotify); + } + itemsToNotify.add(notification); + } - @Override - public boolean unregister(String serviceName, - String serviceVersion, ServiceNotification notification) { - return removeListener(serviceName, serviceVersion, notification); - } + @Override + public boolean unregister(String serviceName, String serviceVersion, ServiceNotification notification) { + return removeListener(serviceName, serviceVersion, notification); + } - private boolean removeListener(String serviceName, - String serviceVersion, ServiceNotification notification) { - List<ServiceNotification> itemsToNotify = callbacks.get(serviceName, - serviceVersion); - boolean removed = false; - if (itemsToNotify != null) { - removed = itemsToNotify.remove(notification); - } - return removed; - } + private boolean removeListener(String serviceName, String serviceVersion, ServiceNotification notification) { + List<ServiceNotification> itemsToNotify = callbacks.get(serviceName, serviceVersion); + boolean removed = false; + if (itemsToNotify != null) { + removed = itemsToNotify.remove(notification); + } + return removed; + } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceRegistrarImpl.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceRegistrarImpl.java index 085e65fe2b7..5e0ad1d40a7 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceRegistrarImpl.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/RemoteServiceRegistrarImpl.java @@ -17,7 +17,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; - import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.messaging.ConnectionNode; import org.eclipse.osee.framework.messaging.services.BaseMessages; @@ -30,12 +29,12 @@ import org.eclipse.osee.framework.messaging.services.ServiceInfoPopulator; */ public class RemoteServiceRegistrarImpl implements RemoteServiceRegistrar { - private ConnectionNode connectionNode; - private ConcurrentHashMap<String, ScheduledFuture<?>> map; - private ConcurrentHashMap<String, UpdateStatus> mapOfUpdateStatus; - private CompositeKeyHashMap<String, String, List<UpdateStatus>> mapForReplys; - private ScheduledExecutorService executor; - private HealthRequestListener healthRequestListener; + private final ConnectionNode connectionNode; + private final ConcurrentHashMap<String, ScheduledFuture<?>> map; + private final ConcurrentHashMap<String, UpdateStatus> mapOfUpdateStatus; + private final CompositeKeyHashMap<String, String, List<UpdateStatus>> mapForReplys; + private final ScheduledExecutorService executor; + private final HealthRequestListener healthRequestListener; public RemoteServiceRegistrarImpl(ConnectionNode node, ScheduledExecutorService executor) { this.connectionNode = node; @@ -46,41 +45,48 @@ public class RemoteServiceRegistrarImpl implements RemoteServiceRegistrar { healthRequestListener = new HealthRequestListener(mapForReplys); } + @Override public void start() { - connectionNode.subscribe(BaseMessages.ServiceHealthRequest, healthRequestListener, new OseeMessagingStatusImpl("Failed to subscribe to " + BaseMessages.ServiceHealthRequest.getName(), RemoteServiceRegistrarImpl.class)); + connectionNode.subscribe(BaseMessages.ServiceHealthRequest, healthRequestListener, new OseeMessagingStatusImpl( + "Failed to subscribe to " + BaseMessages.ServiceHealthRequest.getName(), RemoteServiceRegistrarImpl.class)); } + @Override public void stop() { - connectionNode.unsubscribe(BaseMessages.ServiceHealthRequest, healthRequestListener, new OseeMessagingStatusImpl("Failed to subscribe to " + BaseMessages.ServiceHealthRequest.getName(), RemoteServiceRegistrarImpl.class)); + connectionNode.unsubscribe(BaseMessages.ServiceHealthRequest, healthRequestListener, new OseeMessagingStatusImpl( + "Failed to subscribe to " + BaseMessages.ServiceHealthRequest.getName(), RemoteServiceRegistrarImpl.class)); } @Override public RegisteredServiceReference registerService(String serviceName, String serviceVersion, String serviceUniqueId, URI broker, ServiceInfoPopulator infoPopulator, int refreshRateInSeconds) { String key = getKey(serviceName, serviceVersion, serviceUniqueId); if (!mapOfUpdateStatus.containsKey(key)) { - UpdateStatus updateStatus = new UpdateStatus(this.connectionNode, serviceName, serviceVersion, serviceUniqueId, broker, refreshRateInSeconds, infoPopulator); - ScheduledFuture<?> scheduled = executor.scheduleAtFixedRate(updateStatus, 0, refreshRateInSeconds, TimeUnit.SECONDS); + UpdateStatus updateStatus = + new UpdateStatus(this.connectionNode, serviceName, serviceVersion, serviceUniqueId, broker, + refreshRateInSeconds, infoPopulator); + ScheduledFuture<?> scheduled = + executor.scheduleAtFixedRate(updateStatus, 0, refreshRateInSeconds, TimeUnit.SECONDS); map.put(key, scheduled); mapOfUpdateStatus.put(key, updateStatus); addToReplyMap(serviceName, serviceVersion, updateStatus); } return new ServiceReferenceImp(mapOfUpdateStatus.get(key)); } - - private String getKey(String serviceName, String serviceVersion, String serviceUniqueId){ + + private String getKey(String serviceName, String serviceVersion, String serviceUniqueId) { return serviceName + serviceVersion + serviceUniqueId; } @Override public boolean unregisterService(String serviceName, String serviceVersion, String serviceUniqueId) { - String key = getKey(serviceName, serviceVersion, serviceUniqueId); - + String key = getKey(serviceName, serviceVersion, serviceUniqueId); + UpdateStatus updateStatus = mapOfUpdateStatus.remove(key); - if(updateStatus != null){ + if (updateStatus != null) { updateStatus.close(); removeFromReplyMap(serviceName, serviceVersion, updateStatus); } - + ScheduledFuture<?> scheduled = map.remove(key); if (scheduled == null) { return false; @@ -108,7 +114,7 @@ public class RemoteServiceRegistrarImpl implements RemoteServiceRegistrar { void updateService(String key) { UpdateStatus update = mapOfUpdateStatus.get(key); - if(update != null){ + if (update != null) { update.run(); } } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceHealthPlusTimeout.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceHealthPlusTimeout.java index 1e19b566c55..076696df7f9 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceHealthPlusTimeout.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceHealthPlusTimeout.java @@ -14,25 +14,23 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealth; /** * @author Andrew M. Finkbeiner - * */ public class ServiceHealthPlusTimeout { - private ServiceHealth health; - private long shouldHaveRenewedTime; - - public ServiceHealthPlusTimeout(ServiceHealth health, - long shouldHaveRenewedTime) { - this.health = health; - this.shouldHaveRenewedTime = shouldHaveRenewedTime; - } + private final ServiceHealth health; + private final long shouldHaveRenewedTime; + + public ServiceHealthPlusTimeout(ServiceHealth health, long shouldHaveRenewedTime) { + this.health = health; + this.shouldHaveRenewedTime = shouldHaveRenewedTime; + } + + public boolean isTimedOut(long currentSystemTime) { + return currentSystemTime > shouldHaveRenewedTime; + } + + public ServiceHealth getServiceHealth() { + return health; + } - public boolean isTimedOut(long currentSystemTime){ - return (currentSystemTime > shouldHaveRenewedTime); - } - - public ServiceHealth getServiceHealth(){ - return health; - } - } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceLookupAndRegistrarLifeCycle.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceLookupAndRegistrarLifeCycle.java index 0af6148064d..a6877b02a55 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceLookupAndRegistrarLifeCycle.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceLookupAndRegistrarLifeCycle.java @@ -13,7 +13,6 @@ package org.eclipse.osee.framework.messaging.services.internal; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.logging.Level; - import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.messaging.MessageService; @@ -27,81 +26,85 @@ import org.osgi.util.tracker.ServiceTracker; /** * @author Andrew M. Finkbeiner - * */ public class ServiceLookupAndRegistrarLifeCycle extends ServiceTracker { - private RemoteServiceRegistrar registrar; - private ServiceRegistration lookupRegistration; - private ServiceRegistration registrarRegistration; - private ClassLoader contextClassLoader; - private RemoteServiceLookupImpl lookup; - /** - * @param context - * @param filter - * @param customizer - */ - public ServiceLookupAndRegistrarLifeCycle(BundleContext context, ClassLoader contextClassLoader) { - super(context, MessageService.class.getName(), null); - this.contextClassLoader = contextClassLoader; - } + private RemoteServiceRegistrar registrar; + private ServiceRegistration lookupRegistration; + private ServiceRegistration registrarRegistration; + private final ClassLoader contextClassLoader; + private RemoteServiceLookupImpl lookup; + + /** + * @param context + * @param filter + * @param customizer + */ + public ServiceLookupAndRegistrarLifeCycle(BundleContext context, ClassLoader contextClassLoader) { + super(context, MessageService.class.getName(), null); + this.contextClassLoader = contextClassLoader; + } + + @Override + public Object addingService(ServiceReference reference) { + OseeLog.log(Activator.class, Level.INFO, String.format("Found %s service.", MessageService.class.getName())); + OseeLog.log(Activator.class, Level.FINEST, String.format("GOING TO GET THE REF")); + MessageService messageService = (MessageService) context.getService(reference); + OseeLog.log(Activator.class, Level.FINEST, String.format("got the service ref")); + ScheduledExecutorService executor = Executors.newScheduledThreadPool(2); + OseeLog.log(Activator.class, Level.FINEST, String.format("got exec")); + try { + OseeLog.log(Activator.class, Level.FINEST, String.format("set context classloader")); + Thread.currentThread().setContextClassLoader(contextClassLoader); + OseeLog.log(Activator.class, Level.FINEST, String.format("done set context classloader")); + registrar = new RemoteServiceRegistrarImpl(messageService.getDefault(), executor); + OseeLog.log(Activator.class, Level.FINEST, + String.format("Getting ready to start %s.", RemoteServiceRegistrarImpl.class.getName())); + registrar.start(); + OseeLog.log(Activator.class, Level.FINEST, + String.format("started %s.", RemoteServiceRegistrarImpl.class.getName())); + lookup = new RemoteServiceLookupImpl(messageService.getDefault(), executor); + OseeLog.log(Activator.class, Level.FINEST, + String.format("Getting ready to start %s.", RemoteServiceLookupImpl.class.getName())); + lookup.start(); + OseeLog.log(Activator.class, Level.FINEST, + String.format("started %s.", RemoteServiceLookupImpl.class.getName())); + + lookupRegistration = context.registerService(RemoteServiceLookup.class.getName(), lookup, null); + OseeLog.log(Activator.class, Level.INFO, String.format("Registered %s.", RemoteServiceLookup.class.getName())); + registrarRegistration = context.registerService(RemoteServiceRegistrar.class.getName(), registrar, null); + OseeLog.log(Activator.class, Level.INFO, + String.format("Registered %s.", RemoteServiceRegistrar.class.getName())); + } catch (OseeCoreException ex) { + OseeLog.log(ServiceLookupAndRegistrarLifeCycle.class, Level.SEVERE, ex); + } + return super.addingService(reference); + } + + @Override + public void removedService(ServiceReference reference, Object service) { + commonShutdown(); + super.removedService(reference, service); + } - @Override - public Object addingService(ServiceReference reference) { - OseeLog.log(Activator.class, Level.INFO, String.format("Found %s service.", MessageService.class.getName())); - OseeLog.log(Activator.class, Level.FINEST, String.format("GOING TO GET THE REF")); - MessageService messageService = (MessageService) context.getService(reference); - OseeLog.log(Activator.class, Level.FINEST, String.format("got the service ref")); - ScheduledExecutorService executor = Executors.newScheduledThreadPool(2); - OseeLog.log(Activator.class, Level.FINEST, String.format("got exec")); - try{ - OseeLog.log(Activator.class, Level.FINEST, String.format("set context classloader")); - Thread.currentThread().setContextClassLoader(contextClassLoader); - OseeLog.log(Activator.class, Level.FINEST, String.format("done set context classloader")); - registrar = new RemoteServiceRegistrarImpl(messageService.getDefault(), executor); - OseeLog.log(Activator.class, Level.FINEST, String.format("Getting ready to start %s.", RemoteServiceRegistrarImpl.class.getName())); - registrar.start(); - OseeLog.log(Activator.class, Level.FINEST, String.format("started %s.", RemoteServiceRegistrarImpl.class.getName())); - lookup = new RemoteServiceLookupImpl(messageService.getDefault(), executor); - OseeLog.log(Activator.class, Level.FINEST, String.format("Getting ready to start %s.", RemoteServiceLookupImpl.class.getName())); - lookup.start(); - OseeLog.log(Activator.class, Level.FINEST, String.format("started %s.", RemoteServiceLookupImpl.class.getName())); - - lookupRegistration = context.registerService(RemoteServiceLookup.class.getName(), lookup, null); - OseeLog.log(Activator.class, Level.INFO, String.format("Registered %s.", RemoteServiceLookup.class.getName())); - registrarRegistration = context.registerService(RemoteServiceRegistrar.class.getName(), registrar, null); - OseeLog.log(Activator.class, Level.INFO, String.format("Registered %s.", RemoteServiceRegistrar.class.getName())); - } catch (OseeCoreException ex){ - OseeLog.log(ServiceLookupAndRegistrarLifeCycle.class, Level.SEVERE, ex); - } - return super.addingService(reference); - } + @Override + public void close() { + commonShutdown(); + super.close(); + } - @Override - public void removedService(ServiceReference reference, Object service) { - commonShutdown(); - super.removedService(reference, service); - } + private void commonShutdown() { + if (lookupRegistration != null) { + lookupRegistration.unregister(); + lookupRegistration = null; + lookup.stop(); + } + if (registrarRegistration != null) { + registrarRegistration.unregister(); + registrarRegistration = null; + registrar.stop(); + } - @Override - public void close() { - commonShutdown(); - super.close(); - } + } - private void commonShutdown(){ - if(lookupRegistration != null){ - lookupRegistration.unregister(); - lookupRegistration = null; - lookup.stop(); - } - if(registrarRegistration != null){ - registrarRegistration.unregister(); - registrarRegistration = null; - registrar.stop(); - } - - } - - } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceReferenceImp.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceReferenceImp.java index e6c6806721b..20f4813b8fc 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceReferenceImp.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/ServiceReferenceImp.java @@ -14,16 +14,15 @@ import org.eclipse.osee.framework.messaging.services.RegisteredServiceReference; /** * @author Andrew M. Finkbeiner - * */ class ServiceReferenceImp implements RegisteredServiceReference { UpdateStatus updateStatus; - ServiceReferenceImp(UpdateStatus updateStatus){ + ServiceReferenceImp(UpdateStatus updateStatus) { this.updateStatus = updateStatus; } - + @Override public void update() { updateStatus.run(); diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/UpdateStatus.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/UpdateStatus.java index 08ad188d3f1..91d50518931 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/UpdateStatus.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/services/internal/UpdateStatus.java @@ -20,39 +20,40 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealth; /** * @author Andrew M. Finkbeiner - * */ public class UpdateStatus implements Runnable { - private ConnectionNode connectionNode; - private ServiceInfoPopulator infoPopulator; - private ServiceHealth health; - private String errorMsg; - - UpdateStatus(ConnectionNode connectionNode, String serviceName, String serviceVersion, String serviceUniqueId, URI broker, int refreshRateInSeconds, ServiceInfoPopulator infoPopulator){ - this.connectionNode = connectionNode; - health = new ServiceHealth(); - health.setBrokerURI(broker.toASCIIString()); - health.setServiceName(serviceName); - health.setServiceVersion(serviceVersion); - health.setServiceUniqueId(serviceUniqueId); - health.setRefreshRateInSeconds(refreshRateInSeconds); - health.setStopping(false); - errorMsg = String.format("Failed to send %s to %s v[%s][%s]", BaseMessages.ServiceHealth.getName(), health.getServiceName(), - health.getServiceVersion(), health.getServiceUniqueId()); - this.infoPopulator = infoPopulator; - } - - @Override - public synchronized void run() { - try { - health.getServiceDescription().clear(); - infoPopulator.updateServiceInfo(health.getServiceDescription()); - connectionNode.send(BaseMessages.ServiceHealth, health, new OseeMessagingStatusImpl(errorMsg, UpdateStatus.class)); - } catch (Exception ex) { - OseeLog.log(UpdateStatus.class, Level.SEVERE, ex); - } - } + private final ConnectionNode connectionNode; + private final ServiceInfoPopulator infoPopulator; + private final ServiceHealth health; + private final String errorMsg; + + UpdateStatus(ConnectionNode connectionNode, String serviceName, String serviceVersion, String serviceUniqueId, URI broker, int refreshRateInSeconds, ServiceInfoPopulator infoPopulator) { + this.connectionNode = connectionNode; + health = new ServiceHealth(); + health.setBrokerURI(broker.toASCIIString()); + health.setServiceName(serviceName); + health.setServiceVersion(serviceVersion); + health.setServiceUniqueId(serviceUniqueId); + health.setRefreshRateInSeconds(refreshRateInSeconds); + health.setStopping(false); + errorMsg = + String.format("Failed to send %s to %s v[%s][%s]", BaseMessages.ServiceHealth.getName(), + health.getServiceName(), health.getServiceVersion(), health.getServiceUniqueId()); + this.infoPopulator = infoPopulator; + } + + @Override + public synchronized void run() { + try { + health.getServiceDescription().clear(); + infoPopulator.updateServiceInfo(health.getServiceDescription()); + connectionNode.send(BaseMessages.ServiceHealth, health, new OseeMessagingStatusImpl(errorMsg, + UpdateStatus.class)); + } catch (Exception ex) { + OseeLog.log(UpdateStatus.class, Level.SEVERE, ex); + } + } public synchronized void close() { health.setStopping(true); |