001: /**
002: *
003: * Licensed to the Apache Software Foundation (ASF) under one or more
004: * contributor license agreements. See the NOTICE file distributed with
005: * this work for additional information regarding copyright ownership.
006: * The ASF licenses this file to You under the Apache License, Version 2.0
007: * (the "License"); you may not use this file except in compliance with
008: * the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package org.apache.openejb.jee;
018:
019: import javax.xml.bind.annotation.XmlAccessType;
020: import javax.xml.bind.annotation.XmlAccessorType;
021: import javax.xml.bind.annotation.XmlAttribute;
022: import javax.xml.bind.annotation.XmlElement;
023: import javax.xml.bind.annotation.XmlID;
024: import javax.xml.bind.annotation.XmlType;
025: import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
026: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
027: import java.util.ArrayList;
028: import java.util.List;
029: import java.util.Map;
030: import java.util.LinkedHashMap;
031:
032: /**
033: * The assembly-descriptorType defines
034: * application-assembly information.
035: * <p/>
036: * The application-assembly information consists of the
037: * following parts: the definition of security roles, the
038: * definition of method permissions, the definition of
039: * transaction attributes for enterprise beans with
040: * container-managed transaction demarcation, the definition
041: * of interceptor bindings, a list of
042: * methods to be excluded from being invoked, and a list of
043: * exception types that should be treated as application exceptions.
044: * <p/>
045: * All the parts are optional in the sense that they are
046: * omitted if the lists represented by them are empty.
047: * <p/>
048: * Providing an assembly-descriptor in the deployment
049: * descriptor is optional for the ejb-jar file producer.
050: */
051: @XmlAccessorType(XmlAccessType.FIELD)
052: @XmlType(name="assembly-descriptorType",propOrder={"securityRole","methodPermission","containerTransaction","interceptorBinding","messageDestination","excludeList","applicationException"})
053: public class AssemblyDescriptor {
054:
055: @XmlElement(name="security-role",required=true)
056: protected List<SecurityRole> securityRole;
057: @XmlElement(name="method-permission",required=true)
058: protected List<MethodPermission> methodPermission;
059: @XmlElement(name="container-transaction",required=true)
060: protected List<ContainerTransaction> containerTransaction;
061: @XmlElement(name="interceptor-binding",required=true)
062: protected List<InterceptorBinding> interceptorBinding;
063: @XmlElement(name="message-destination",required=true)
064: protected List<MessageDestination> messageDestination;
065: @XmlElement(name="exclude-list")
066: protected ExcludeList excludeList;
067: @XmlElement(name="application-exception",required=true)
068: protected List<ApplicationException> applicationException;
069: @XmlAttribute
070: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
071: @XmlID
072: protected String id;
073:
074: public List<SecurityRole> getSecurityRole() {
075: if (securityRole == null) {
076: securityRole = new ArrayList<SecurityRole>();
077: }
078: return this .securityRole;
079: }
080:
081: public List<MethodPermission> getMethodPermission() {
082: if (methodPermission == null) {
083: methodPermission = new ArrayList<MethodPermission>();
084: }
085: return this .methodPermission;
086: }
087:
088: public List<ContainerTransaction> getContainerTransaction() {
089: if (containerTransaction == null) {
090: containerTransaction = new ArrayList<ContainerTransaction>();
091: }
092: return this .containerTransaction;
093: }
094:
095: public Map<String, List<MethodTransaction>> getMethodTransactions(
096: String ejbName) {
097: Map<String, List<MethodTransaction>> methods = new LinkedHashMap<String, List<MethodTransaction>>();
098: for (ContainerTransaction transaction : getContainerTransaction()) {
099:
100: for (Method method : transaction.getMethod()) {
101: if (method.getEjbName().equals(ejbName)) {
102: String methodName = method.getMethodName();
103: List<MethodTransaction> list = methods
104: .get(methodName);
105: if (list == null) {
106: list = new ArrayList<MethodTransaction>();
107: methods.put(methodName, list);
108: }
109: list.add(new MethodTransaction(transaction
110: .getTransAttribute(), method));
111: }
112: }
113: }
114: return methods;
115: }
116:
117: public List<InterceptorBinding> getInterceptorBinding() {
118: if (interceptorBinding == null) {
119: interceptorBinding = new ArrayList<InterceptorBinding>();
120: }
121: return this .interceptorBinding;
122: }
123:
124: public InterceptorBinding addInterceptorBinding(
125: InterceptorBinding binding) {
126: getInterceptorBinding().add(binding);
127: return binding;
128: }
129:
130: public List<MessageDestination> getMessageDestination() {
131: if (messageDestination == null) {
132: messageDestination = new ArrayList<MessageDestination>();
133: }
134: return this .messageDestination;
135: }
136:
137: public ExcludeList getExcludeList() {
138: if (excludeList == null) {
139: excludeList = new ExcludeList();
140: }
141: return excludeList;
142: }
143:
144: public void setExcludeList(ExcludeList value) {
145: this .excludeList = value;
146: }
147:
148: public List<ApplicationException> getApplicationException() {
149: if (applicationException == null) {
150: applicationException = new ArrayList<ApplicationException>();
151: }
152: return this .applicationException;
153: }
154:
155: public String getId() {
156: return id;
157: }
158:
159: public void setId(String value) {
160: this.id = value;
161: }
162:
163: }
|