Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.

1 /*2 * Copyright 2002 by3 * <a HREF="http://www.coridan.com">Coridan</a>4 * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>5 *6 * The contents of this file are subject to the Mozilla Public License Version7 * 1.1 (the "License"); you may not use this file except in compliance with the8 * License. You may obtain a copy of the License at9 * http://www.mozilla.org/MPL/10 *11 * Software distributed under the License is distributed on an "AS IS" basis,12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License13 * for the specific language governing rights and limitations under the14 * License.15 *16 * The Original Code is "MantaRay" (TM).17 *18 * The Initial Developer of the Original Code is Nimo 23-MAR-2004.19 * Portions created by the Initial Developer are Copyright (C) 200620 * Coridan Inc. All Rights Reserved.21 *22 * Contributor(s): all the names of the contributors are added in the source23 * code where applicable.24 *25 * Alternatively, the contents of this file may be used under the terms of the26 * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the27 * provisions of LGPL are applicable instead of those above. If you wish to28 * allow use of your version of this file only under the terms of the LGPL29 * License and not to allow others to use your version of this file under30 * the MPL, indicate your decision by deleting the provisions above and31 * replace them with the notice and other provisions required by the LGPL.32 * If you do not delete the provisions above, a recipient may use your version33 * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.34 35 *36 * This library is free software; you can redistribute it and/or modify it37 * under the terms of the MPL as stated above or under the terms of the GNU38 * Lesser General Public License as published by the Free Software Foundation;39 * either version 2.1 of the License, or any later version.40 *41 * This library is distributed in the hope that it will be useful, but WITHOUT42 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or43 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public44 * License for more details.45 */46 package org.mr.api.jms;47 48 importjavax.jms.Destination;49 importjavax.jms.JMSException;50 importjavax.naming.NamingException;51 importjavax.naming.Reference;52 importjavax.naming.Referenceable;53 importjavax.naming.StringRefAddr;54 55 importorg.mr.core.util.byteable.Byteable;56 importorg.mr.core.util.byteable.ByteableInputStream;57 importorg.mr.core.util.byteable.ByteableOutputStream;58 importorg.mr.core.util.byteable.ByteableRegistry;59 60 importjava.io.IOException;61 importjava.io.Serializable;62 63 /**64 * @author Nimo 23-MAR-200465 *66 * A Destination object encapsulates a provider-specific address. The JMS API does not define a 67 * standard address syntax. Although a standard address syntax was considered, it was decided 68 * that the differences in address semantics between existing message-oriented middleware (MOM) 69 * products were too wide to bridge with a single syntax. Since Destination is an administered 70 * object, it may contain provider-specific configuration information in addition to its address.71 * The JMS API also supports a client's use of provider-specific address names.72 * Destination objects support concurrent use.73 * A Destination object is a JMS administered object.74 * JMS administered objects are objects containing configuration information that are created by an 75 * administrator and later used by JMS clients. They make it practical to administer the JMS API in 76 * the enterprise. Although the interfaces for administered objects do not explicitly depend on the 77 * Java Naming and Directory Interface (JNDI) API, the JMS API establishes the convention that JMS 78 * clients find administered objects by looking them up in a JNDI namespace.79 * An administrator can place an administered object anywhere in a namespace. The JMS API does not80 * define a naming policy.81 * It is expected that JMS providers will provide the tools an administrator needs to create and 82 * configure administered objects in a JNDI namespace. JMS provider implementations of administered 83 * objects should implement the javax.naming.Referenceable and java.io.Serializable interfaces so that 84 * they can be stored in all JNDI naming contexts. In addition, it is recommended that these 85 * implementations follow the JavaBeansTM design patterns.86 * 87 * This strategy provides several benefits:88 * 89 * It hides provider-specific details from JMS clients.90 * It abstracts JMS administrative information into objects in the Java programming language 91 * ("Java objects") that are easily organized and administered from a common management console.92 * Since there will be JNDI providers for all popular naming services, JMS providers can deliver 93 * one implementation of administered objects that will run everywhere. An administered object 94 * should not hold on to any remote resources. Its lookup should not use remote resources other95 * than those used by the JNDI API itself. Clients should think of administered objects as local 96 * Java objects. Looking them up should not have any hidden side effects or use surprising amounts 97 * of local resources98 * 99 */100 101 publicclass MantaDestination implementsDestination, Byteable, Referenceable, Serializable {102 103 /**104 * generated <code>serialVersionUID</code>105 */106 privatestaticfinallong serialVersionUID = 6875502999461250235L;107 //The name of the destination that this object refers to.108 String destinationName;109 110 /**111 * Constructors for the destination object112 */113 public MantaDestination() {114 }115 public MantaDestination(String s) {116 this.destinationName = s;117 }118 public MantaDestination(Destination d) {119 this.destinationName = d.toString();120 }121 122 publicvoid setPhysicalName(String name) throwsJMSException {123 destinationName = name;124 }125 126 publicString getPhysicalName() {127 return destinationName;128 }129 130 publicString toString() {131 return destinationName;132 }133 134 //Byteable methods-------------------135 finalstaticString objName = "MantaDest";136 publicString getByteableName() {137 138 return objName;139 }140 141 publicvoid toBytes(ByteableOutputStream out) throwsIOException {142 143 out.writeUTF(destinationName);144 out.flush();145 146 }147 148 publicByteable createInstance(ByteableInputStream in) throwsIOException {149 150 MantaDestination cd = newMantaDestination();151 cd.destinationName = in.readUTF();152 return cd;153 }154 155 publicvoid registerToByteableRegistry() {156 ByteableRegistry.registerByteableFactory(getByteableName() , this);157 158 }159 160 publicstaticvoid register() throwsJMSException{161 MantaDestination instance = newMantaDestination();162 instance.registerToByteableRegistry();163 }164 165 /**166 * A destination may be looked up from a JNDI. Therefore it must167 * implement the Referencable interface and have this method inside it.168 * 169 */170 publicReference getReference() throwsNamingException {171 172 returnnewReference (173 getClass().getName(),174 newStringRefAddr("name",this.destinationName),175 MantaDestinationFactory.class.getName(),176 null177 );178 179 }180 }181