Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.apache.tomcat.bayeux.request;
 
 import static org.jboss.web.CoyoteMessages.MESSAGES;
 
 import java.util.List;
 
 
Handshake request Bayeux message.

Author(s):
Guy A. Molinari
Filip Hanik
Version:
1.0
 
 public class MetaUnsubscribeRequest extends RequestBase implements BayeuxRequest {
 
     protected static HashMap<String,ObjectresponseTemplate = new HashMap<String,Object>();
 
     static {
     }
 
     public MetaUnsubscribeRequest(TomcatBayeux tbHttpEvent eventJSONObject jsReqthrows JSONException {
         super(tbeventjsReq);
     }


    
Check client request for validity. Per section 4.6.1 of the Bayuex spec a connect request must contain: 1) The "/meta/unsubscribe" channel identifier. 2) The clientId. 3) The subscription. This is the name of the channel of interest, or a pattern.

Returns:
HttpError This method returns null if no errors were found
 
     public HttpError validate() {
         if(==null|| (!this.getTomcatBayeux().hasClient()))
             return new HttpError(400, .invalidBayeuxClientId(), null);
         if (==null||.length()==0)
             return new HttpError(400, .noBayeuxSubscription(), null);
         return null;//no error
     }

    
De-register interest for one or more channels. Per section 2.2.1 of the Bayeux spec, a pattern may be specified. Sever relationships.
 
     public int process(int prevopsthrows BayeuxException {
         prevops = super.process(prevops);
          = (HashMap<StringObject>).clone();
         ClientImpl client = (ClientImpl)getTomcatBayeux().getClient();
         HttpError error = validate();
         if (error == null) {
             boolean wildcard = .indexOf('*')!=-1;
             boolean unsubscribed = false;
             if (wildcard) {
                 List<Channelchannels = getTomcatBayeux().getChannels();
                 Iterator<Channelit = channels.iterator();
                 while (it.hasNext()) {
                     ChannelImpl ch = (ChannelImpl)it.next();
                    if (ch.matches()) {
                        ch.unsubscribe(client);
                        unsubscribed = true;
                    }
                }
            }else {
                ChannelImpl ch = (ChannelImpl)getTomcatBayeux().getChannel(,true);
                ch.unsubscribe(client);
                unsubscribed = true;
            }
            .put(., Boolean.valueOf(unsubscribed));
            ((HashMap.get(.)).put("reconnect""retry");
            ((HashMap.get(.)).put("interval"getReconnectInterval());
        }else {
            .put(.error.toString());
            ((HashMap.get(.)).put("reconnect""handshake");
            if (client==nullclient = TomcatBayeux.getErrorClient();
        }
        .put(.client.getId());
        try {
            JSONObject obj = new JSONObject();
            addToDeliveryQueue(clientobj);
        } catch (ServletException x) {
            throw new BayeuxException(x);
        } catch (IOException x) {
            throw new BayeuxException(x);
        }
        return 0;
    }
New to GrepCode? Check out our FAQ X