001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb;
023:
024: import java.util.HashMap;
025:
026: import javax.ejb.MessageDriven;
027:
028: import javax.ejb.ActivationConfigProperty;
029:
030: /**
031: * // *
032: *
033: * @author <a href="mailto:bill@jboss.org">William DeCoste</a>
034: * @version $Revision: 63408 $
035: */
036: public class MessageDrivenImpl implements MessageDriven {
037: private String name = "";
038: private String mn = "";
039: private String desc = "";
040: private Class listenerInterface = Object.class;
041:
042: private HashMap activationConfigProperties = new HashMap();
043:
044: public MessageDrivenImpl(String name,
045: ActivationConfigProperty[] activationConfigProperties) {
046: this .name = name;
047: for (ActivationConfigProperty property : activationConfigProperties) {
048: this .activationConfigProperties.put(
049: property.propertyName(), property);
050: }
051: }
052:
053: public String name() {
054: return name;
055: }
056:
057: public ActivationConfigProperty[] activationConfig() {
058: ActivationConfigProperty[] properties = new ActivationConfigProperty[activationConfigProperties
059: .size()];
060: activationConfigProperties.values().toArray(properties);
061: return properties;
062: }
063:
064: public Class annotationType() {
065: return javax.ejb.MessageDriven.class;
066: }
067:
068: public String mappedName() {
069: return mn;
070: }
071:
072: public void setMappedName(String mn) {
073: this .mn = mn;
074: }
075:
076: public String description() {
077: return desc;
078: }
079:
080: public void setDescription(String desc) {
081: this .desc = desc;
082: }
083:
084: public Class messageListenerInterface() {
085: return listenerInterface;
086: }
087:
088: public void setMessageListenerInterface(Class clazz) {
089: this .listenerInterface = clazz;
090: }
091:
092: public void merge(MessageDriven annotation) {
093: if (name.length() == 0)
094: name = annotation.name();
095:
096: if (mn.length() == 0)
097: mn = annotation.mappedName();
098:
099: if (desc.length() == 0)
100: desc = annotation.description();
101:
102: Class messageListenerInterface = annotation
103: .messageListenerInterface();
104: if (messageListenerInterface != null
105: && !messageListenerInterface.getName().equals(
106: Object.class.getName()))
107: listenerInterface = annotation.messageListenerInterface();
108:
109: for (ActivationConfigProperty property : annotation
110: .activationConfig()) {
111: if (!activationConfigProperties.containsKey(property
112: .propertyName())) {
113: activationConfigProperties.put(property.propertyName(),
114: property);
115: }
116: }
117: }
118: }
|