Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
GRANITE DATA SERVICES Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S. This file is part of the Granite Data Services Platform. Granite Data Services is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. Granite Data Services is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA, or see <http://www.gnu.org/licenses/>.
 
 package org.granite.gravity.selector;
 
 
 import  javax.jms.JMSException;
 
 import  org.apache.activemq.command.Response;
 import  org.apache.activemq.filter.BooleanExpression;
 import  org.apache.activemq.filter.MessageEvaluationContext;
 import  org.apache.activemq.selector.SelectorParser;
 import  org.apache.activemq.state.CommandVisitor;
 
 import  flex.messaging.messages.Message;

Author(s):
William DRAI
 
 public class ActiveMQMessageSelector implements MessageSelector {
 
     private BooleanExpression expression;
 
 
     public ActiveMQMessageSelector(String selector) {
         try {
             this. = SelectorParser.parse(selector);
         }
         catch (Exception e) {
             throw new RuntimeException("ActiveMQ SelectorParser error " + selectore);
         }
     }
 
     public boolean accept(Message message) {
         try {
             MessageEvaluationContext context = new MessageEvaluationContext();
             MessageAdapter ma = new MessageAdapter(message);
             context.setMessageReference(ma);
 
             return .matches(context);
         }
         catch (Exception e) {
             throw new RuntimeException("ActiveMQ selector accept error " + messagee);
         }
     }
 
 
     private static class MessageAdapter extends org.apache.activemq.command.Message {
         private Message message = null;
 
         public MessageAdapter(Message message) {
             this. = message;
         }
 
         @Override
         public Object getProperty(String namethrows IOException {
             return .getHeader(name);
         }
 
         @Override
         public org.apache.activemq.command.Message copy() {
             return null;
         }
 
         public Response visit(CommandVisitor visitorthrows Exception {
             return null;
         }
 
         public byte getDataStructureType() {
             return 0;
         }
 
 		public void clearBody() throws JMSException {
 		}
 
 		public void storeContent() {	// Since ActiveMQ 5.7
 		}
     }
New to GrepCode? Check out our FAQ X