KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > command > ActiveMQTempDestination


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.command;
16
17 import javax.jms.JMSException JavaDoc;
18 import org.apache.activemq.ActiveMQConnection;
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21
22 /**
23  * @openwire:marshaller
24  * @version $Revision: 1.5 $
25  */

26 abstract public class ActiveMQTempDestination extends ActiveMQDestination{
27
28     private static final Log log=LogFactory.getLog(ActiveMQTempDestination.class);
29     protected transient ActiveMQConnection connection;
30     protected transient String JavaDoc connectionId;
31     protected transient int sequenceId;
32
33     public ActiveMQTempDestination(){
34     }
35
36     public ActiveMQTempDestination(String JavaDoc name){
37         super(name);
38     }
39
40     public ActiveMQTempDestination(String JavaDoc connectionId,long sequenceId){
41         super(connectionId+":"+sequenceId);
42     }
43
44     public boolean isTemporary(){
45         return true;
46     }
47
48     public void delete() throws JMSException JavaDoc{
49         connection.deleteTempDestination(this);
50     }
51
52     public ActiveMQConnection getConnection(){
53         return connection;
54     }
55
56     public void setConnection(ActiveMQConnection connection){
57         this.connection=connection;
58     }
59
60     public void setPhysicalName(String JavaDoc physicalName){
61         super.setPhysicalName(physicalName);
62         if(!isComposite()){
63             // Parse off the sequenceId off the end.
64
//this can fail if the temp destination is
65
//generated by another JMS system via the JMS<->JMS Bridge
66
int p=this.physicalName.lastIndexOf(":");
67             if(p>=0){
68                 String JavaDoc seqStr=this.physicalName.substring(p+1).trim();
69                 if(seqStr!=null&&seqStr.length()>0){
70                     try{
71                         sequenceId=Integer.parseInt(seqStr);
72                     }catch(NumberFormatException JavaDoc e){
73                         log.debug("Did not parse sequence Id from "+physicalName);
74                     }
75                     // The rest should be the connection id.
76
connectionId=this.physicalName.substring(0,p);
77                 }
78             }
79         }
80     }
81
82     public String JavaDoc getConnectionId(){
83         return connectionId;
84     }
85
86     public void setConnectionId(String JavaDoc connectionId){
87         this.connectionId=connectionId;
88     }
89
90     public int getSequenceId(){
91         return sequenceId;
92     }
93 }
94
Popular Tags