KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > MessageDrivenImpl


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb;
23
24 import java.util.HashMap JavaDoc;
25
26 import javax.ejb.MessageDriven JavaDoc;
27
28 import javax.ejb.ActivationConfigProperty JavaDoc;
29
30 /**
31  * // *
32  *
33  * @author <a HREF="mailto:bill@jboss.org">William DeCoste</a>
34  * @version $Revision: 44268 $
35  */

36 public class MessageDrivenImpl implements MessageDriven JavaDoc
37 {
38    private String JavaDoc name = "";
39    private String JavaDoc mn = "";
40    private String JavaDoc desc = "";
41    private Class JavaDoc listenerInterface = Object JavaDoc.class;
42
43    private HashMap JavaDoc activationConfigProperties = new HashMap JavaDoc();
44
45    public MessageDrivenImpl(String JavaDoc name, ActivationConfigProperty JavaDoc[] activationConfigProperties)
46    {
47       this.name = name;
48       for (ActivationConfigProperty JavaDoc property : activationConfigProperties)
49       {
50          this.activationConfigProperties.put(property.propertyName(), property);
51       }
52    }
53
54    public String JavaDoc name()
55    {
56       return name;
57    }
58
59    public ActivationConfigProperty JavaDoc[] activationConfig()
60    {
61       ActivationConfigProperty JavaDoc[] properties = new ActivationConfigProperty JavaDoc[activationConfigProperties.size()];
62       activationConfigProperties.values().toArray(properties);
63       return properties;
64    }
65
66    public Class JavaDoc annotationType()
67    {
68       return javax.ejb.MessageDriven JavaDoc.class;
69    }
70    
71    public String JavaDoc mappedName() { return mn;}
72    public void setMappedName(String JavaDoc mn) { this.mn = mn; }
73    public String JavaDoc description() { return desc;}
74    public void setDescription(String JavaDoc desc) { this.desc = desc; }
75    public Class JavaDoc messageListenerInterface() { return listenerInterface;}
76    public void setMessageListenerInterface(Class JavaDoc clazz) { this.listenerInterface = clazz; }
77    
78    public void merge(MessageDriven JavaDoc annotation)
79    {
80       if (name.length() == 0)
81          name = annotation.name();
82       
83       if (mn.length() == 0)
84          mn = annotation.mappedName();
85       
86       if (desc.length() == 0)
87          desc = annotation.description();
88       
89       for (ActivationConfigProperty JavaDoc property : annotation.activationConfig())
90       {
91          if (!activationConfigProperties.containsKey(property.propertyName()))
92          {
93             activationConfigProperties.put(property.propertyName(), property);
94          }
95       }
96    }
97 }
98
Popular Tags