org.apache.openejb.jee.SessionBean Maven / Gradle / Ivy
The newest version!
/**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.openejb.jee;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Arrays;
/**
* The session-beanType declares an session bean. The
* declaration consists of:
*
* - an optional description
* - an optional display name
* - an optional icon element that contains a small and a large
* icon file name
* - a name assigned to the enterprise bean
* in the deployment description
* - an optional mapped-name element that can be used to provide
* vendor-specific deployment information such as the physical
* jndi-name of the session bean's remote home/business interface.
* This element is not required to be supported by all
* implementations. Any use of this element is non-portable.
* - the names of all the remote or local business interfaces,
* if any
* - the names of the session bean's remote home and
* remote interfaces, if any
* - the names of the session bean's local home and
* local interfaces, if any
* - the name of the session bean's web service endpoint
* interface, if any
* - the session bean's implementation class
* - the session bean's state management type
* - an optional declaration of the session bean's timeout method.
* - the optional session bean's transaction management type.
* If it is not present, it is defaulted to Container.
* - an optional list of the session bean class and/or
* superclass around-invoke methods.
* - an optional declaration of the bean's
* environment entries
* - an optional declaration of the bean's EJB references
* - an optional declaration of the bean's local
* EJB references
* - an optional declaration of the bean's web
* service references
* - an optional declaration of the security role
* references
* - an optional declaration of the security identity
* to be used for the execution of the bean's methods
* - an optional declaration of the bean's resource
* manager connection factory references
* - an optional declaration of the bean's resource
* environment references.
* - an optional declaration of the bean's message
* destination references
*
* The elements that are optional are "optional" in the sense
* that they are omitted when if lists represented by them are
* empty.
*
* Either both the local-home and the local elements or both
* the home and the remote elements must be specified for the
* session bean.
*
* The service-endpoint element may only be specified if the
* bean is a stateless session bean.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "session-beanType", propOrder = {
"descriptions",
"displayNames",
"icon",
"ejbName",
"mappedName",
"home",
"remote",
"localHome",
"local",
"businessLocal",
"businessRemote",
"localBean",
"serviceEndpoint",
"ejbClass",
"sessionType",
"loadOnStartup",
"timeoutMethod",
"initMethod",
"removeMethod",
"transactionType",
"concurrencyType",
"aroundInvoke",
"envEntry",
"ejbRef",
"ejbLocalRef",
"serviceRef",
"resourceRef",
"resourceEnvRef",
"messageDestinationRef",
"persistenceContextRef",
"persistenceUnitRef",
"postConstruct",
"preDestroy",
"postActivate",
"prePassivate",
"securityRoleRef",
"securityIdentity",
"dependsOn"
})
public class SessionBean implements RemoteBean, Session, TimerConsumer {
@XmlTransient
protected TextMap description = new TextMap();
@XmlTransient
protected TextMap displayName = new TextMap();
@XmlElement(name = "icon", required = true)
protected LocalCollection icon = new LocalCollection();
@XmlElement(name = "ejb-name", required = true)
protected String ejbName;
@XmlElement(name = "mapped-name")
protected String mappedName;
protected String home;
protected String remote;
@XmlElement(name = "local-home")
protected String localHome;
protected String local;
@XmlElement(name = "business-local")
protected LinkedHashSet businessLocal;
@XmlElement(name = "business-remote")
protected LinkedHashSet businessRemote;
@XmlElement(name = "local-bean")
protected EmptyType localBean;
@XmlElement(name = "service-endpoint")
protected String serviceEndpoint;
@XmlElement(name = "ejb-class")
protected String ejbClass;
@XmlElement(name = "session-type")
protected SessionType sessionType = SessionType.STATELESS;
@XmlElement(name = "timeout-method")
protected NamedMethod timeoutMethod;
@XmlElement(name = "init-method", required = true)
protected List initMethod;
@XmlElement(name = "remove-method", required = true)
protected List removeMethod;
@XmlElement(name = "transaction-type")
protected TransactionType transactionType;
@XmlElement(name = "concurrency-type")
protected ConcurrencyType concurrencyType;
@XmlElement(name = "around-invoke", required = true)
protected List aroundInvoke;
@XmlElement(name = "env-entry", required = true)
protected KeyedCollection envEntry;
@XmlElement(name = "ejb-ref", required = true)
protected KeyedCollection ejbRef;
@XmlElement(name = "ejb-local-ref", required = true)
protected KeyedCollection ejbLocalRef;
@XmlElement(name = "service-ref", required = true)
protected KeyedCollection serviceRef;
@XmlElement(name = "resource-ref", required = true)
protected KeyedCollection resourceRef;
@XmlElement(name = "resource-env-ref", required = true)
protected KeyedCollection resourceEnvRef;
@XmlElement(name = "message-destination-ref", required = true)
protected KeyedCollection messageDestinationRef;
@XmlElement(name = "persistence-context-ref", required = true)
protected KeyedCollection persistenceContextRef;
@XmlElement(name = "persistence-unit-ref", required = true)
protected KeyedCollection persistenceUnitRef;
@XmlElement(name = "post-construct", required = true)
protected List postConstruct;
@XmlElement(name = "pre-destroy", required = true)
protected List preDestroy;
@XmlElement(name = "post-activate", required = true)
protected List postActivate;
@XmlElement(name = "pre-passivate", required = true)
protected List prePassivate;
@XmlElement(name = "security-role-ref", required = true)
protected List securityRoleRef;
@XmlElement(name = "security-identity")
protected SecurityIdentity securityIdentity;
@XmlElement(name = "load-on-startup")
protected Boolean loadOnStartup;
@XmlElementWrapper(name = "depends-on")
@XmlElement(name = "ejb-name")
protected List dependsOn;
@XmlAttribute
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlID
protected String id;
public SessionBean() {
}
public SessionBean(String ejbName, String ejbClass, SessionType sessionType) {
this.ejbName = ejbName;
this.ejbClass = ejbClass;
this.sessionType = sessionType;
}
public String getJndiConsumerName() {
return ejbName;
}
@XmlElement(name = "description", required = true)
public Text[] getDescriptions() {
return description.toArray();
}
public void setDescriptions(Text[] text) {
description.set(text);
}
public String getDescription() {
return description.get();
}
@XmlElement(name = "display-name", required = true)
public Text[] getDisplayNames() {
return displayName.toArray();
}
public void setDisplayNames(Text[] text) {
displayName.set(text);
}
public String getDisplayName() {
return displayName.get();
}
public Collection getIcons() {
if (icon == null) {
icon = new LocalCollection();
}
return icon;
}
public Map getIconMap() {
if (icon == null) {
icon = new LocalCollection();
}
return icon.toMap();
}
public Icon getIcon() {
return icon.getLocal();
}
public String getEjbName() {
return ejbName;
}
/**
* The ejb-nameType specifies an enterprise bean's name. It is
* used by ejb-name elements. This name is assigned by the
* ejb-jar file producer to name the enterprise bean in the
* ejb-jar file's deployment descriptor. The name must be
* unique among the names of the enterprise beans in the same
* ejb-jar file.
*
* There is no architected relationship between the used
* ejb-name in the deployment descriptor and the JNDI name that
* the Deployer will assign to the enterprise bean's home.
*
* The name for an entity bean must conform to the lexical
* rules for an NMTOKEN.
*
* Example:
*
* EmployeeService
*/
public void setEjbName(String value) {
this.ejbName = value;
}
public String getMappedName() {
return mappedName;
}
public void setMappedName(String value) {
this.mappedName = value;
}
public String getHome() {
return home;
}
public void setHome(String value) {
this.home = value;
}
public String getRemote() {
return remote;
}
public void setRemote(String value) {
this.remote = value;
}
public void setHomeAndRemote(String home, String remote) {
this.remote = remote;
this.home = home;
}
public void setHomeAndRemote(Class> home, Class> remote) {
this.remote = remote.getName();
this.home = home.getName();
}
public void setHomeAndLocal(String localHome, String local) {
this.local = local;
this.localHome = localHome;
}
public void setHomeAndLocal(Class> localHome, Class> local) {
this.local = local.getName();
this.localHome = localHome.getName();
}
public String getLocalHome() {
return localHome;
}
public void setLocalHome(String value) {
this.localHome = value;
}
public String getLocal() {
return local;
}
public void setLocal(String value) {
this.local = value;
}
public Collection getBusinessLocal() {
if (businessLocal == null){
businessLocal = new LinkedHashSet();
}
return businessLocal;
}
public void addBusinessLocal(String businessLocal) {
if (businessLocal == null) return;
getBusinessLocal().add(businessLocal);
}
public void addBusinessLocal(Class businessLocal) {
addBusinessLocal(businessLocal.getName());
}
public Collection getBusinessRemote() {
if (businessRemote == null){
businessRemote = new LinkedHashSet();
}
return businessRemote;
}
public void addBusinessRemote(String businessRemote) {
if (businessRemote == null) return;
getBusinessRemote().add(businessRemote);
}
public void addBusinessRemote(Class businessRemote) {
addBusinessRemote(businessRemote.getName());
}
public EmptyType getLocalBean() {
return localBean;
}
public void setLocalBean(EmptyType localBean) {
this.localBean = localBean;
}
public String getServiceEndpoint() {
return serviceEndpoint;
}
public void setServiceEndpoint(String value) {
this.serviceEndpoint = value;
}
public String getEjbClass() {
return ejbClass;
}
public void setEjbClass(String value) {
this.ejbClass = value;
}
public void setEjbClass(Class value) {
this.ejbClass = value.getName();
}
public SessionType getSessionType() {
return sessionType;
}
public void setSessionType(SessionType value) {
this.sessionType = value;
}
public NamedMethod getTimeoutMethod() {
return timeoutMethod;
}
public void setTimeoutMethod(NamedMethod value) {
this.timeoutMethod = value;
}
public List getInitMethod() {
if (initMethod == null) {
initMethod = new ArrayList();
}
return this.initMethod;
}
public List getRemoveMethod() {
if (removeMethod == null) {
removeMethod = new ArrayList();
}
return this.removeMethod;
}
public TransactionType getTransactionType() {
return transactionType;
}
public ConcurrencyType getConcurrencyType() {
return concurrencyType;
}
public void setTransactionType(TransactionType value) {
this.transactionType = value;
}
public void setConcurrencyType(ConcurrencyType value) {
this.concurrencyType = value;
}
public List getAroundInvoke() {
if (aroundInvoke == null) {
aroundInvoke = new ArrayList();
}
return this.aroundInvoke;
}
public void addAroundInvoke(String method){
assert ejbClass != null: "Set the ejbClass before calling this method";
getAroundInvoke().add(new AroundInvoke(ejbClass, method));
}
public Collection getEnvEntry() {
if (envEntry == null) {
envEntry = new KeyedCollection();
}
return this.envEntry;
}
public Map getEnvEntryMap() {
if (envEntry == null) {
envEntry = new KeyedCollection();
}
return this.envEntry.toMap();
}
public Collection getEjbRef() {
if (ejbRef == null) {
ejbRef = new KeyedCollection();
}
return this.ejbRef;
}
public Map getEjbRefMap() {
if (ejbRef == null) {
ejbRef = new KeyedCollection();
}
return this.ejbRef.toMap();
}
public Collection getEjbLocalRef() {
if (ejbLocalRef == null) {
ejbLocalRef = new KeyedCollection();
}
return this.ejbLocalRef;
}
public Map getEjbLocalRefMap() {
if (ejbLocalRef == null) {
ejbLocalRef = new KeyedCollection();
}
return this.ejbLocalRef.toMap();
}
public Collection getServiceRef() {
if (serviceRef == null) {
serviceRef = new KeyedCollection();
}
return this.serviceRef;
}
public Map getServiceRefMap() {
if (serviceRef == null) {
serviceRef = new KeyedCollection();
}
return this.serviceRef.toMap();
}
public Collection getResourceRef() {
if (resourceRef == null) {
resourceRef = new KeyedCollection();
}
return this.resourceRef;
}
public Map getResourceRefMap() {
if (resourceRef == null) {
resourceRef = new KeyedCollection();
}
return this.resourceRef.toMap();
}
public Collection getResourceEnvRef() {
if (resourceEnvRef == null) {
resourceEnvRef = new KeyedCollection();
}
return this.resourceEnvRef;
}
public Map getResourceEnvRefMap() {
if (resourceEnvRef == null) {
resourceEnvRef = new KeyedCollection();
}
return this.resourceEnvRef.toMap();
}
public Collection getMessageDestinationRef() {
if (messageDestinationRef == null) {
messageDestinationRef = new KeyedCollection();
}
return this.messageDestinationRef;
}
public Map getMessageDestinationRefMap() {
if (messageDestinationRef == null) {
messageDestinationRef = new KeyedCollection();
}
return this.messageDestinationRef.toMap();
}
public Collection getPersistenceContextRef() {
if (persistenceContextRef == null) {
persistenceContextRef = new KeyedCollection();
}
return this.persistenceContextRef;
}
public Map getPersistenceContextRefMap() {
if (persistenceContextRef == null) {
persistenceContextRef = new KeyedCollection();
}
return this.persistenceContextRef.toMap();
}
public Collection getPersistenceUnitRef() {
if (persistenceUnitRef == null) {
persistenceUnitRef = new KeyedCollection();
}
return this.persistenceUnitRef;
}
public Map getPersistenceUnitRefMap() {
if (persistenceUnitRef == null) {
persistenceUnitRef = new KeyedCollection();
}
return this.persistenceUnitRef.toMap();
}
public List getPostConstruct() {
if (postConstruct == null) {
postConstruct = new ArrayList();
}
return this.postConstruct;
}
public void addPostConstruct(String method){
assert ejbClass != null: "Set the ejbClass before calling this method";
getPostConstruct().add(new LifecycleCallback(ejbClass, method));
}
public List getPreDestroy() {
if (preDestroy == null) {
preDestroy = new ArrayList();
}
return this.preDestroy;
}
public void addPreDestroy(String method){
assert ejbClass != null: "Set the ejbClass before calling this method";
getPreDestroy().add(new LifecycleCallback(ejbClass, method));
}
public List getPostActivate() {
if (postActivate == null) {
postActivate = new ArrayList();
}
return this.postActivate;
}
public void addPostActivate(String method){
assert ejbClass != null: "Set the ejbClass before calling this method";
getPostActivate().add(new LifecycleCallback(ejbClass, method));
}
public List getPrePassivate() {
if (prePassivate == null) {
prePassivate = new ArrayList();
}
return this.prePassivate;
}
public void addPrePassivate(String method){
assert ejbClass != null: "Set the ejbClass before calling this method";
getPrePassivate().add(new LifecycleCallback(ejbClass, method));
}
public List getSecurityRoleRef() {
if (securityRoleRef == null) {
securityRoleRef = new ArrayList();
}
return this.securityRoleRef;
}
public SecurityIdentity getSecurityIdentity() {
return securityIdentity;
}
public void setSecurityIdentity(SecurityIdentity value) {
this.securityIdentity = value;
}
public List getDependsOn() {
return dependsOn;
}
public void setDependsOn(String... ejbNames) {
setDependsOn(Arrays.asList(ejbNames));
}
public void setDependsOn(List ejbNames) {
this.dependsOn = new ArrayList(ejbNames);
}
public boolean hasLoadOnStartup() {
return loadOnStartup != null;
}
public boolean getLoadOnStartup() {
return loadOnStartup != null && loadOnStartup;
}
public void setLoadOnStartup(boolean loadOnStartup) {
this.loadOnStartup = loadOnStartup;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy