Changeset 34


Ignore:
Timestamp:
06/10/13 18:09:19 (11 years ago)
Author:
stoda
Message:

Some refactoring done

Location:
trunk/objectmq
Files:
2 added
4 deleted
13 edited
17 copied

Legend:

Unmodified
Added
Removed
  • trunk/objectmq/.classpath

    r27 r34  
    99        <classpathentry kind="lib" path="lib/rabbitmq-client.jar">
    1010                <attributes>
    11                         <attribute name="javadoc_location" value="file:/home/sergi/Documentos/Sergi/Java/workspace/objectmq/lib/rabbitmq-java-client-javadoc-3.0.1/"/>
     11                        <attribute name="javadoc_location" value="file:/home/sergi/workspace/Java/objectmq/lib/rabbitmq-java-client-javadoc-3.0.1/"/>
    1212                </attributes>
    1313        </classpathentry>
  • trunk/objectmq/src/omq/client/listener/ResponseListener.java

    r20 r34  
    1 package omq.client.remote.response;
     1package omq.client.listener;
    22
     3import java.io.IOException;
    34import java.util.Hashtable;
    45import java.util.Map;
     
    67
    78import omq.client.proxy.Proxymq;
    8 import omq.common.remote.RemoteListener;
     9import omq.common.util.OmqConnectionFactory;
    910import omq.common.util.ParameterQueue;
    1011
    1112import com.rabbitmq.client.AMQP.BasicProperties;
     13import com.rabbitmq.client.Channel;
     14import com.rabbitmq.client.Connection;
    1215import com.rabbitmq.client.ConsumerCancelledException;
    1316import com.rabbitmq.client.QueueingConsumer;
     
    2225 *
    2326 */
    24 public class ResponseListener extends RemoteListener {
     27public class ResponseListener extends Thread {
    2528        private static ResponseListener rListener;
     29
     30        private Connection connection;
     31        private Channel channel;
     32        private QueueingConsumer consumer;
     33        private boolean killed = false;
    2634        private Map<String, Map<String, byte[]>> results;
    2735
     
    3341         */
    3442        protected ResponseListener(Properties env) throws Exception {
    35                 super(env);
     43                connection = OmqConnectionFactory.getNewConnection(env);
     44                channel = connection.createChannel();
     45
    3646                // Init the hashtable (it's concurrent)
    3747                this.results = new Hashtable<String, Map<String, byte[]>>();
     
    6373
    6474                                // Stores the new response
    65                                 Map<String, byte[]> proxyResults = results.get(props.getAppId());
     75                                Map<String, byte[]> proxyResults = results
     76                                                .get(props.getAppId());
    6677
    6778                                // Put the result into the proxy results and notify him
     
    108119         * @throws Exception
    109120         */
    110         public static ResponseListener getRequestListener(Properties env) throws Exception {
     121        public static ResponseListener getRequestListener(Properties env)
     122                        throws Exception {
    111123                if (rListener == null) {
    112124                        rListener = new ResponseListener(env);
     
    136148                return rListener;
    137149        }
     150       
     151        public synchronized Channel getChannel() throws Exception {
     152                return connection.createChannel();
     153        }
    138154
    139155        /**
     
    156172        }
    157173
     174        /**
     175         * Interrupt and kill the Thread
     176         *
     177         * @throws IOException
     178         */
     179        public void kill() throws IOException {
     180                interrupt();
     181                killed = true;
     182                channel.close();
     183                connection.close();
     184        }
     185
    158186        // Revisar això
    159187        public void registerProxy(Proxymq proxy) {
  • trunk/objectmq/src/omq/client/proxy/Proxymq.java

    r30 r34  
    66import java.lang.reflect.Proxy;
    77import java.util.Collection;
    8 import java.util.Date;
    98import java.util.HashMap;
    109import java.util.Hashtable;
     
    1514import omq.client.annotation.AsyncMethod;
    1615import omq.client.annotation.SyncMethod;
    17 import omq.client.remote.response.ResponseListener;
     16import omq.client.listener.ResponseListener;
    1817import omq.common.event.Event;
    1918import omq.common.event.EventDispatcher;
  • trunk/objectmq/src/omq/common/broker/Broker.java

    r30 r34  
    55
    66import omq.Remote;
     7import omq.client.listener.ResponseListener;
    78import omq.client.proxy.Proxymq;
    8 import omq.client.remote.response.ResponseListener;
    99import omq.common.event.Event;
    1010import omq.common.event.EventDispatcher;
     
    1818import omq.exception.RemoteException;
    1919import omq.exception.SerializerException;
    20 import omq.server.remote.request.RemoteObject;
     20import omq.server.RemoteObject;
    2121
    2222import com.rabbitmq.client.Channel;
  • trunk/objectmq/src/omq/common/util/ParameterQueue.java

    r24 r34  
    1212         */
    1313
    14         public static String SERIALIZERNAME = "revo.serializer";
    15         public static String ENABLECOMPRESSION = "revo.compression";
     14        public static String SERIALIZERNAME = "omq.serializer";
     15        public static String ENABLECOMPRESSION = "omq.compression";
    1616
    17         public static String SERVER_HOST = "revo.host";
    18         public static String SERVER_PORT = "revo.port";
    19         public static String SERVER_REGISTRY = "revo.registry";
     17        public static String SERVER_HOST = "omq.host";
     18        public static String SERVER_PORT = "omq.port";
     19        public static String SERVER_REGISTRY = "omq.registry";
    2020
    21         public static String USER_NAME = "revo.username";
    22         public static String USER_PASS = "revo.pass";
     21        public static String USER_NAME = "omq.username";
     22        public static String USER_PASS = "omq.pass";
    2323
    24         public static String RPC_EXCHANGE = "revo.rpc_exchange";
    25         public static String RPC_QUEUE = "revo.rpc_queue";
    26         public static String RPC_ROUTING_KEY = "revo.routing_key";
     24        public static String RPC_EXCHANGE = "omq.rpc_exchange";
    2725
    28         public static String RPC_REPLY_QUEUE = "revo.reply_queue_rpc";
    29         public static String EVENT_REPLY_QUEUE = "revo.reply_queue_event";
     26        public static String RPC_REPLY_QUEUE = "omq.reply_queue_rpc";
     27        public static String EVENT_REPLY_QUEUE = "omq.reply_queue_event";
    3028
    31         public static String ENABLE_SSL = "revo.enable_ssl";
    32         public static String DEBUGFILE = "revo.debug_file";
     29        public static String ENABLE_SSL = "omq.enable_ssl";
     30        public static String DEBUGFILE = "omq.debug_file";
    3331
    3432        public static String RETRY_TIME_CONNECTION = "omq.retry_connection";
  • trunk/objectmq/src/omq/common/util/Serializer.java

    r19 r34  
    1010import omq.exception.EnvironmentException;
    1111import omq.exception.SerializerException;
    12 import omq.server.remote.request.RemoteObject;
     12import omq.server.RemoteObject;
    1313
    1414/**
  • trunk/objectmq/src/omq/common/util/Serializers/GsonImp.java

    r25 r34  
    77import omq.common.message.Response;
    88import omq.exception.SerializerException;
    9 import omq.server.remote.request.RemoteObject;
     9import omq.server.RemoteObject;
    1010
    1111import com.google.gson.Gson;
  • trunk/objectmq/src/omq/common/util/Serializers/ISerializer.java

    r14 r34  
    55import omq.common.message.Response;
    66import omq.exception.SerializerException;
    7 import omq.server.remote.request.RemoteObject;
     7import omq.server.RemoteObject;
    88
    99/**
  • trunk/objectmq/src/omq/common/util/Serializers/JavaImp.java

    r31 r34  
    1111import omq.common.message.Response;
    1212import omq.exception.SerializerException;
    13 import omq.server.remote.request.RemoteObject;
     13import omq.server.RemoteObject;
    1414
    1515/**
  • trunk/objectmq/src/omq/common/util/Serializers/KryoImp.java

    r25 r34  
    1212import omq.common.message.Response;
    1313import omq.exception.SerializerException;
    14 import omq.server.remote.request.RemoteObject;
     14import omq.server.RemoteObject;
    1515
    1616/**
  • trunk/objectmq/src/omq/server/InvocationThread.java

    r31 r34  
    1 package omq.server.remote.request;
     1package omq.server;
    22
    33import java.util.concurrent.BlockingQueue;
  • trunk/objectmq/src/omq/server/RemoteObject.java

    r31 r34  
    1 package omq.server.remote.request;
     1package omq.server;
    22
    33import java.io.IOException;
  • trunk/objectmq/src/omq/server/RemoteWrapper.java

    r31 r34  
    1 package omq.server.remote.request;
     1package omq.server;
    22
    33import java.util.ArrayList;
  • trunk/objectmq/test/calculatorTest/Calculator.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import java.io.IOException;
  • trunk/objectmq/test/calculatorTest/CalculatorImpl.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import java.io.IOException;
     
    66import omq.common.broker.Broker;
    77import omq.exception.SerializerException;
    8 import omq.server.remote.request.RemoteObject;
     8import omq.server.RemoteObject;
    99
    1010public class CalculatorImpl extends RemoteObject implements Calculator {
  • trunk/objectmq/test/calculatorTest/ClientTest.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import static org.junit.Assert.assertEquals;
  • trunk/objectmq/test/calculatorTest/Message.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import java.io.Serializable;
  • trunk/objectmq/test/calculatorTest/ServerTest.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import java.util.Properties;
  • trunk/objectmq/test/calculatorTest/ZeroEvent.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import omq.common.event.Event;
  • trunk/objectmq/test/calculatorTest/ZeroListener.java

    r31 r34  
    1 package omq.ztest.calculator;
     1package calculatorTest;
    22
    33import omq.common.event.EventListener;
     
    55public class ZeroListener extends EventListener<ZeroEvent> {
    66
    7         public ZeroListener(String topic){
     7        public ZeroListener(String topic) {
    88                super(topic);
    99        }
    10        
     10
    1111        @Override
    1212        public void notifyEvent(ZeroEvent event) {
    1313                System.out.println(event.getZeroMessage());
    1414        }
    15 
    1615}
  • trunk/objectmq/test/farmTest/Animal.java

    r31 r34  
    1 package omq.ztest.farm;
     1package farmTest;
    22
    33import java.io.Serializable;
  • trunk/objectmq/test/farmTest/Cow.java

    r31 r34  
    1 package omq.ztest.farm;
     1package farmTest;
    22
    33public class Cow implements Animal {
  • trunk/objectmq/test/farmTest/Farm.java

    r31 r34  
    1 package omq.ztest.farm;
     1package farmTest;
    22
    33import omq.Remote;
  • trunk/objectmq/test/farmTest/FarmImpl.java

    r31 r34  
    1 package omq.ztest.farm;
     1package farmTest;
    22
    3 import omq.server.remote.request.RemoteObject;
     3import omq.server.RemoteObject;
    44
    55public class FarmImpl extends RemoteObject implements Farm {
  • trunk/objectmq/test/farmTest/FarmTest.java

    r31 r34  
    1 package omq.ztest.farm;
     1package farmTest;
    22
    33import static org.junit.Assert.assertEquals;
     
    2828                // listen to.
    2929                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
    30                 env.setProperty(ParameterQueue.RPC_QUEUE, "rpc_queue");
    31                 env.setProperty(ParameterQueue.RPC_ROUTING_KEY, "rpc");
    3230
    3331                farm = new FarmImpl();
     
    4947                // Set info about where the message will be sent
    5048                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
    51                 env.setProperty(ParameterQueue.RPC_ROUTING_KEY, "rpc");
    5249
    5350                // Set info about the queue & the exchange where the ResponseListener
  • trunk/objectmq/test/farmTest/Pig.java

    r31 r34  
    1 package omq.ztest.farm;
     1package farmTest;
    22
    33public class Pig implements Animal {
  • trunk/objectmq/test/test/ClientImpl.java

    r27 r34  
    99import omq.common.broker.Broker;
    1010import omq.exception.RemoteException;
    11 import omq.server.remote.request.RemoteObject;
     11import omq.server.RemoteObject;
    1212
    1313public class ClientImpl extends RemoteObject implements Client {
  • trunk/objectmq/test/test2/CarImpl.java

    r29 r34  
    55import omq.common.broker.Broker;
    66import omq.exception.RemoteException;
    7 import omq.server.remote.request.RemoteObject;
     7import omq.server.RemoteObject;
    88
    99public class CarImpl extends RemoteObject implements Car {
  • trunk/objectmq/test/test2/MobileImpl.java

    r29 r34  
    44import java.util.List;
    55
    6 import omq.server.remote.request.RemoteObject;
     6import omq.server.RemoteObject;
    77
    88public class MobileImpl extends RemoteObject implements Mobile {
Note: See TracChangeset for help on using the changeset viewer.