Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 17080 invoked from network); 22 Dec 2005 10:27:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Dec 2005 10:27:11 -0000 Received: (qmail 41595 invoked by uid 500); 22 Dec 2005 10:27:11 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 41568 invoked by uid 500); 22 Dec 2005 10:27:10 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 41552 invoked by uid 99); 22 Dec 2005 10:27:10 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2005 02:27:10 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 22 Dec 2005 02:27:09 -0800 Received: (qmail 16895 invoked by uid 65534); 22 Dec 2005 10:26:49 -0000 Message-ID: <20051222102649.16894.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r358550 - in /incubator/activemq/trunk/activecluster/src/java/org/activecluster: DestinationMarshaller.java impl/DefaultDestinationMarshaller.java impl/NodeState.java Date: Thu, 22 Dec 2005 10:26:48 -0000 To: activemq-commits@geronimo.apache.org From: rajdavies@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: rajdavies Date: Thu Dec 22 02:26:43 2005 New Revision: 358550 URL: http://svn.apache.org/viewcvs?rev=358550&view=rev Log: Revert back to javax.jms.Destination instead of Strings and added support for a DestinationMarshaller Added: incubator/activemq/trunk/activecluster/src/java/org/activecluster/DestinationMarshaller.java incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/DefaultDestinationMarshaller.java incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/NodeState.java Added: incubator/activemq/trunk/activecluster/src/java/org/activecluster/DestinationMarshaller.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activecluster/src/java/org/activecluster/DestinationMarshaller.java?rev=358550&view=auto ============================================================================== --- incubator/activemq/trunk/activecluster/src/java/org/activecluster/DestinationMarshaller.java (added) +++ incubator/activemq/trunk/activecluster/src/java/org/activecluster/DestinationMarshaller.java Thu Dec 22 02:26:43 2005 @@ -0,0 +1,44 @@ +/** + * + * Copyright 2004 The Apache Software Foundation + * + * Licensed 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.activecluster; + +import javax.jms.Destination; + +/** + * A simple marshaller for Destinations + * + * @version $Revision: 1.5 $ + */ +public interface DestinationMarshaller { + + /** + * Builds a destination from a destinationName + * @param destinationName + * + * @return the destination to send messages to all members of the cluster + */ + public Destination getDestination(String destinationName); + + /** + * Gets a destination's physical name + * @param destination + * @return the destination's physical name + */ + public String getDestinationName(Destination destination); +} Added: incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/DefaultDestinationMarshaller.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/DefaultDestinationMarshaller.java?rev=358550&view=auto ============================================================================== --- incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/DefaultDestinationMarshaller.java (added) +++ incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/DefaultDestinationMarshaller.java Thu Dec 22 02:26:43 2005 @@ -0,0 +1,73 @@ +/** + * + * Copyright 2004 The Apache Software Foundation + * + * Licensed 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.activecluster.impl; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Queue; +import javax.jms.Topic; +import org.activecluster.DestinationMarshaller; +import org.activemq.command.ActiveMQTopic; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A simple marshaller for Destinations + * + * @version $Revision: 1.5 $ + */ +public class DefaultDestinationMarshaller implements DestinationMarshaller { + private final static Log log = LogFactory.getLog(DefaultDestinationMarshaller.class); + /** + * Builds a destination from a destinationName + * @param destinationName + * + * @return the destination to send messages to all members of the cluster + */ + public Destination getDestination(String destinationName){ + return new ActiveMQTopic(destinationName); + } + + /** + * Gets a destination's physical name + * @param destination + * @return the destination's physical name + */ + public String getDestinationName(Destination destination){ + String result = null; + if (destination != null){ + if (destination instanceof Topic){ + Topic topic = (Topic) destination; + try{ + result = topic.getTopicName(); + }catch(JMSException e){ + log.error("Failed to get topic name for " + destination,e); + } + }else{ + Queue queue = (Queue) destination; + try{ + result = queue.getQueueName(); + }catch(JMSException e){ + log.error("Failed to get queue name for " + destination,e); + } + } + } + return result; + } +} \ No newline at end of file Added: incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/NodeState.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/NodeState.java?rev=358550&view=auto ============================================================================== --- incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/NodeState.java (added) +++ incubator/activemq/trunk/activecluster/src/java/org/activecluster/impl/NodeState.java Thu Dec 22 02:26:43 2005 @@ -0,0 +1,151 @@ +/** + * + * Copyright 2004 The Apache Software Foundation + * + * Licensed 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.activecluster.impl; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Map; +import org.activecluster.DestinationMarshaller; +import org.activecluster.Node; +/** + * Default implementation of a remote Node + * + * @version $Revision: 1.3 $ + */ +public class NodeState implements Externalizable{ + private static final long serialVersionUID=-3909792803360045064L; + private String name; + private String destinationName; + protected Map state; + protected boolean coordinator; + + /** + * DefaultConstructor + * + */ + public NodeState(){ + } + + /** + * Construct a NodeState from a Node + * @param node + * @param marshaller + */ + public NodeState(Node node, DestinationMarshaller marshaller){ + this.name = node.getName(); + this.destinationName = marshaller.getDestinationName(node.getDestination()); + this.state = node.getState(); + this.coordinator = node.isCoordinator(); + } + + /** + * @return pretty print of the node + */ + public String toString(){ + return "NodeState[<"+name+">destinationName: "+destinationName+" state: "+state+"]"; + } + + /** + * @return Returns the coordinator. + */ + public boolean isCoordinator(){ + return coordinator; + } + + /** + * @param coordinator + * The coordinator to set. + */ + public void setCoordinator(boolean coordinator){ + this.coordinator=coordinator; + } + + /** + * @return Returns the destinationName. + */ + public String getDestinationName(){ + return destinationName; + } + + /** + * @param destinationName + * The destinationName to set. + */ + public void setDestinationName(String destinationName){ + this.destinationName=destinationName; + } + + /** + * @return Returns the name. + */ + public String getName(){ + return name; + } + + /** + * @param name + * The name to set. + */ + public void setName(String name){ + this.name=name; + } + + /** + * @return Returns the state. + */ + public Map getState(){ + return state; + } + + /** + * @param state + * The state to set. + */ + public void setState(Map state){ + this.state=state; + } + + /** + * write to a stream + * + * @param out + * @throws IOException + */ + public void writeExternal(ObjectOutput out) throws IOException{ + out.writeUTF((name!=null?name:"")); + out.writeUTF((destinationName!=null?destinationName:"")); + out.writeBoolean(coordinator); + out.writeObject(state); + } + + /** + * read from a stream + * + * @param in + * @throws IOException + * @throws ClassNotFoundException + */ + public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException{ + this.name=in.readUTF(); + this.destinationName=in.readUTF(); + this.coordinator=in.readBoolean(); + this.state=(Map) in.readObject(); + } +}