Permalink
Browse files

MAS: Helper classes

  • Loading branch information...
1 parent 439f0f3 commit fbc5a7202aa4c64fe03e90933c20c0df01b83021 @sotty sotty committed Aug 1, 2012
@@ -0,0 +1,34 @@
+package org.drools.mas.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+public class EndPointHelper {
+
+ public static final String DEF_SRC = "/META-INF/service.endpoint.properties";
+
+ public static String getEndPoint( String key ) {
+ Properties props = new Properties();
+ try {
+ InputStream in = EndPointHelper.class.getResourceAsStream( DEF_SRC );
+ if ( in != null ) {
+ props.load( in );
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return (String) props.get( key );
+ }
+
+ public static URL getEndPointURL( String key ) {
+ try {
+ return new URL( getEndPoint( key ) );
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
@@ -0,0 +1,74 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.drools.mas.util.helper;
+
+import org.drools.definition.type.Position;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author salaboy
+ */
+public class NodeLocator implements Serializable {
+
+ @Position(0)
+ private String nodeId;
+
+ @Position(1)
+ private boolean mindNode;
+
+
+ public NodeLocator( String nodeId, boolean mindNode ) {
+ this.nodeId = nodeId;
+ this.mindNode = mindNode;
+ }
+
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public boolean isMindNode() {
+ return mindNode;
+ }
+
+ public void setMindNode(boolean mindNode) {
+ this.mindNode = mindNode;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ NodeLocator that = (NodeLocator) o;
+
+ if (mindNode != that.mindNode) return false;
+ if (nodeId != null ? !nodeId.equals(that.nodeId) : that.nodeId != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = nodeId != null ? nodeId.hashCode() : 0;
+ result = 31 * result + (mindNode ? 1 : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "NodeLocator{" +
+ "nodeId='" + nodeId + '\'' +
+ ", mindNode=" + mindNode +
+ '}';
+ }
+}
+

0 comments on commit fbc5a72

Please sign in to comment.