Merge pull request #5102 from luchua-bc/java/main-method-in-servlet

Java: CWE-489 Query to detect main() method in servlets
This commit is contained in:
Tamás Vajk
2021-02-25 16:05:06 +01:00
committed by GitHub
36 changed files with 2538 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
public class EJBMain implements SessionBean {
/**
* Create the session bean (empty implementation)
*/
public void ejbCreate() throws javax.ejb.CreateException {
System.out.println("EJBMain:ejbCreate()");
}
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void setSessionContext(SessionContext parm1) throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public String doService() {
return null;
}
// BAD - Implement a main method in session bean.
public static void main(String[] args) throws Exception {
EJBMain b = new EJBMain();
b.doService();
}
// GOOD - Not to have a main method in session bean.
}

View File

@@ -0,0 +1,27 @@
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
<qhelp>
<overview>
<p>Debug code can create unintended entry points in a deployed Java EE web application therefore should never make into production. There is no reason to have a main method in a Java EE web application. Having a main method in the Java EE application increases the attack surface that an attacker can exploit to attack the application logic.</p>
</overview>
<recommendation>
<p>Remove the main method from enterprise beans.</p>
</recommendation>
<example>
<p>The following example shows two ways of implementing enterprise beans. In the 'BAD' case, a main method is implemented. In the 'GOOD' case, no main method is implemented.</p>
<sample src="EJBMain.java" />
</example>
<references>
<li>
SonarSource:
<a href="https://rules.sonarsource.com/java/tag/owasp/RSPEC-2653">Web applications should not have a "main" method</a>
</li>
<li>
Carnegie Mellon University:
<a href="https://wiki.sei.cmu.edu/confluence/display/java/ENV06-J.+Production+code+must+not+contain+debugging+entry+points">ENV06-J. Production code must not contain debugging entry points</a>
</li>
</references>
</qhelp>

View File

@@ -0,0 +1,24 @@
/**
* @name Main Method in Enterprise Java Bean
* @description Java EE applications with a main method.
* @kind problem
* @id java/main-method-in-enterprise-bean
* @tags security
* external/cwe-489
*/
import java
import semmle.code.java.J2EE
import MainLib
/** The `main` method in an Enterprise Java Bean. */
class EnterpriseBeanMainMethod extends Method {
EnterpriseBeanMainMethod() {
this.getDeclaringType() instanceof EnterpriseBean and
isMainMethod(this) and
not isTestMethod(this)
}
}
from EnterpriseBeanMainMethod sm
select sm, "Java EE application has a main method."

View File

@@ -0,0 +1,27 @@
/** Definitions related to the main method in a test program. */
import java
/** Holds if `m` is the main method of a Java class with the signature `public static void main(String[] args)`. */
predicate isMainMethod(Method m) {
m.hasName("main") and
m.isStatic() and
m.getReturnType() instanceof VoidType and
m.isPublic() and
m.getNumberOfParameters() = 1 and
m.getParameter(0).getType() instanceof Array
}
/**
* Holds if `m` is a test method indicated by:
* a) in a test directory such as `src/test/java`
* b) in a test package whose name has the word `test`
* c) in a test class whose name has the word `test`
* d) in a test class implementing a test framework such as JUnit or TestNG
*/
predicate isTestMethod(Method m) {
m.getDeclaringType().getName().toLowerCase().matches("%test%") or // Simple check to exclude test classes to reduce FPs
m.getDeclaringType().getPackage().getName().toLowerCase().matches("%test%") or // Simple check to exclude classes in test packages to reduce FPs
exists(m.getLocation().getFile().getAbsolutePath().indexOf("/src/test/java")) or // Match test directory structure of build tools like maven
m instanceof TestMethod // Test method of a test case implementing a test framework such as JUnit or TestNG
}

View File

@@ -0,0 +1,10 @@
public class WebComponentMain implements Servlet {
// BAD - Implement a main method in servlet.
public static void main(String[] args) throws Exception {
// Connect to my server
URL url = new URL("https://www.example.com");
url.openConnection();
}
// GOOD - Not to have a main method in servlet.
}

View File

@@ -0,0 +1,31 @@
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
<qhelp>
<overview>
<p>Debug code can create unintended entry points in a deployed Java EE web application therefore should never make into production. There is no reason to have a main method in a Java EE web application. Having a main method in the Java EE application increases the attack surface that an attacker can exploit to attack the application logic.</p>
</overview>
<recommendation>
<p>Remove the main method from web components including servlets, filters, and listeners.</p>
</recommendation>
<example>
<p>The following example shows two ways of implementing web components. In the 'BAD' case, a main method is implemented. In the 'GOOD' case, no main method is implemented.</p>
<sample src="WebComponentMain.java" />
</example>
<references>
<li>
Fortify:
<a href="https://vulncat.fortify.com/en/detail?id=desc.structural.java.j2ee_badpractices_leftover_debug_code">J2EE Bad Practices: Leftover Debug Code</a>
</li>
<li>
SonarSource:
<a href="https://rules.sonarsource.com/java/tag/owasp/RSPEC-2653">Web applications should not have a "main" method</a>
</li>
<li>
Carnegie Mellon University:
<a href="https://wiki.sei.cmu.edu/confluence/display/java/ENV06-J.+Production+code+must+not+contain+debugging+entry+points">ENV06-J. Production code must not contain debugging entry points</a>
</li>
</references>
</qhelp>

View File

@@ -0,0 +1,57 @@
/**
* @name Main Method in Java EE Web Components
* @description Java EE web applications with a main method.
* @kind problem
* @id java/main-method-in-web-components
* @tags security
* external/cwe-489
*/
import java
import semmle.code.java.frameworks.Servlets
import MainLib
/** The java type `javax.servlet.Filter`. */
class ServletFilterClass extends Class {
ServletFilterClass() { this.getASupertype*().hasQualifiedName("javax.servlet", "Filter") }
}
/** Listener class in the package `javax.servlet` and `javax.servlet.http` */
class ServletListenerClass extends Class {
// Various listener classes of Java EE such as ServletContextListener. They all have a name ending with the word "Listener".
ServletListenerClass() {
this.getASupertype*()
.getQualifiedName()
.regexpMatch([
"javax\\.servlet\\.[a-zA-Z]+Listener", "javax\\.servlet\\.http\\.[a-zA-Z]+Listener"
])
}
}
/** The `main` method in `Servlet` and `Action` of the Spring and Struts framework. */
class WebComponentMainMethod extends Method {
WebComponentMainMethod() {
(
this.getDeclaringType() instanceof ServletClass or
this.getDeclaringType() instanceof ServletFilterClass or
this.getDeclaringType() instanceof ServletListenerClass or
this.getDeclaringType()
.getASupertype*()
.hasQualifiedName("org.apache.struts.action", "Action") or // Struts actions
this.getDeclaringType()
.getASupertype+()
.hasQualifiedName("com.opensymphony.xwork2", "ActionSupport") or // Struts 2 actions
this.getDeclaringType()
.getASupertype+()
.hasQualifiedName("org.springframework.web.struts", "ActionSupport") or // Spring/Struts 2 actions
this.getDeclaringType()
.getASupertype+()
.hasQualifiedName("org.springframework.webflow.execution", "Action") // Spring actions
) and
isMainMethod(this) and
not isTestMethod(this)
}
}
from WebComponentMainMethod sm
select sm, "Web application has a main method."

View File

@@ -0,0 +1 @@
| ServiceBean.java:55:24:55:27 | main | Java EE application has a main method. |

View File

@@ -0,0 +1,59 @@
import javax.ejb.SessionBean;
import javax.ejb.EJBException;
import java.rmi.RemoteException;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
public class ServiceBean implements SessionBean {
protected SessionContext ctx;
private String _serviceName;
/**
* Create the session bean (empty implementation)
*/
public void ejbCreate() throws javax.ejb.CreateException {
System.out.println("ServiceBean:ejbCreate()");
}
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void setSessionContext(SessionContext parm1) throws javax.ejb.EJBException, java.rmi.RemoteException {
}
/**
* Get service name
* @return service name
*/
public String getServiceName() {
return _serviceName;
}
/**
* Set service name
* @param serviceName the service name
*/
public void setServiceName(String serviceName) {
_serviceName = serviceName;
}
/** Do service (no implementation) */
public String doService() {
return null;
}
/** Local unit testing code */
public static void main(String[] args) throws Exception {
ServiceBean b = new ServiceBean();
b.doService();
}
}

View File

@@ -0,0 +1 @@
experimental/Security/CWE/CWE-489/EJBMain.ql

View File

@@ -0,0 +1,25 @@
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.net.URL;
public class ServletContextListenerMain implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("listener starts to work!");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("listener stopped!");
}
// BAD - Implement a main method in servlet listener.
public static void main(String[] args) {
try {
URL url = new URL("https://www.example.com");
url.openConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,2 @@
| ServletContextListenerMain.java:17:21:17:24 | main | Web application has a main method. |
| ServletMain.java:28:21:28:24 | main | Web application has a main method. |

View File

@@ -0,0 +1,33 @@
import javax.servlet.Servlet;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import java.io.IOException;
import java.net.URL;
public class ServletMain implements Servlet {
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
}
public void init(ServletConfig servletConfig) throws ServletException {
}
public ServletConfig getServletConfig() {
return null;
}
public String getServletInfo() {
return null;
}
public void destroy() {
}
// BAD - Implement a main method in servlet.
public static void main(String[] args) throws Exception {
// Connect to my server
URL url = new URL("https://www.example.com");
url.openConnection();
}
}

View File

@@ -0,0 +1 @@
experimental/Security/CWE/CWE-489/WebComponentMain.ql

View File

@@ -0,0 +1 @@
// semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/servlet-api-2.4:${testdir}/../../../../stubs/ejb-3.2

View File

@@ -0,0 +1,71 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The CreateException exception must be included in the throws clauses of
* all create methods defined in an enterprise bean's home or local home
* interface.
*
* <p> This exception is used as a standard application-level exception to
* report a failure to create an EJB object or local object.
*
* @since EJB 1.0
*/
public class CreateException extends java.lang.Exception {
private static final long serialVersionUID = 6295951740865457514L;
/**
* Constructs a CreateException with no detail message.
*/
public CreateException() {
}
/**
* Constructs a CreateException with the specified
* detail message.
*/
public CreateException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,133 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.*;
/**
* Indicates a dependency on the local, no-interface, or remote view of an Enterprise
* JavaBean.
* <p>
* Either the <code>beanName</code> or the <code>lookup</code> element can
* be used to resolve the EJB dependency to its target session bean component.
* It is an error to specify values for both <code>beanName</code> and
* <code>lookup</code>.
* <p>
* If no explicit linking information is provided and there is only one session
* bean within the same application that exposes the matching client view type,
* by default the EJB dependency resolves to that session bean.
*
* @since EJB 3.0
*/
@Target({TYPE, METHOD, FIELD})
@Retention(RUNTIME)
public @interface EJB {
/**
* The logical name of the ejb reference within the declaring component's
* (e.g., java:comp/env) environment.
*/
String name() default "";
/**
* A string describing the bean.
*/
String description() default "";
/**
* The <code>beanName</code> element references the value of the <code>name</code>
* element of the <code>Stateful</code> or <code>Stateless</code> annotation,
* whether defaulted or explicit. If the deployment descriptor was used to define
* the name of the bean, the <code>beanName</code> element references the
* <code>ejb-name</code> element of the bean definition.
* <p>
* The <code>beanName</code> element allows disambiguation if multiple session
* beans in the ejb-jar implement the same interface.
* <p>
* In order to reference a bean in another ejb-jar file in the same application,
* the <code>beanName</code> may be composed of a path name specifying the ejb-jar
* containing the referenced bean with the bean name of the target bean appended and
* separated from the path name by &#35;. The path name is relative to the jar file
* containing the component that is referencing the target bean.
* <p>
* Only applicable if the target EJB is defined within the
* same application or stand-alone module as the declaring component.
*/
String beanName() default "";
/**
* The interface type of the Enterprise Java Bean to which this reference
* is mapped.
* <p>
* Holds one of the following types of the target EJB :
* <ul>
* <li> Local business interface
* <li> Bean class (for no-interface view)
* <li> Remote business interface
* <li> Local Home interface
* <li> Remote Home interface
* </ul>
*/
Class beanInterface() default Object.class;
/**
* The product specific name of the EJB component to which this
* ejb reference should be mapped. This mapped name is often a
* global JNDI name, but may be a name of any form.
* <p>
* Application servers are not required to support any particular
* form or type of mapped name, nor the ability to use mapped names.
* The mapped name is product-dependent and often installation-dependent.
* No use of a mapped name is portable.
*/
String mappedName() default "";
/**
* A portable lookup string containing the JNDI name for the target EJB component.
*
* @since EJB 3.1
*/
String lookup() default "";
}

View File

@@ -0,0 +1,252 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.util.*;
import java.security.Identity;
import java.security.Principal;
import javax.transaction.UserTransaction;
/**
* The EJBContext interface provides an instance with access to the
* container-provided runtime context of an enterprise bean instance.
*
* <p> This interface is extended by the <code>SessionContext</code>,
* <code>EntityContext</code>, and <code>MessageDrivenContext</code> interfaces
* to provide additional methods specific to the enterprise interface bean type.
*
* @see SessionContext
* @see MessageDrivenContext
* @see EntityContext
*
* @since EJB 1.0
*/
public interface EJBContext
{
/**
* Obtain the enterprise bean's remote home interface.
*
* @return The enterprise bean's remote home interface.
*
* @exception java.lang.IllegalStateException if the enterprise bean
* does not have a remote home interface.
*/
EJBHome getEJBHome() throws IllegalStateException;
/**
* Obtain the enterprise bean's local home interface.
*
* @return The enterprise bean's local home interface.
*
* @exception java.lang.IllegalStateException if the enterprise bean
* does not have a local home interface.
*
* @since EJB 2.0
*/
EJBLocalHome getEJBLocalHome() throws IllegalStateException;
/**
* Obtain the enterprise bean's environment properties.
*
* <p><b>Note:</b> If the enterprise bean has no environment properties
* this method returns an empty <code>java.util.Properties</code> object.
* This method never returns <code>null</code>.
*
* @return The environment properties for the enterprise bean.
*
* @deprecated Use the JNDI naming context java:comp/env to access
* enterprise bean's environment.
*/
Properties getEnvironment();
/**
* Obtain the <code>java.security.Identity</code> of the caller.
*
* This method is deprecated in EJB 1.1. The Container
* is allowed to return always <code>null</code> from this method. The enterprise
* bean should use the <code>getCallerPrincipal</code> method instead.
*
* @return The <code>Identity</code> object that identifies the caller.
*
* @deprecated Use Principal getCallerPrincipal() instead.
*/
Identity getCallerIdentity();
/**
* Obtain the <code>java.security.Principal</code> that identifies the caller.
*
* @return The <code>Principal</code> object that identifies the caller. This
* method never returns <code>null</code>.
*
* @exception IllegalStateException The Container throws the exception
* if the instance is not allowed to call this method.
*
* @since EJB 1.1
*/
Principal getCallerPrincipal() throws IllegalStateException;
/**
* Test if the caller has a given role.
*
* <p>This method is deprecated in EJB 1.1. The enterprise bean
* should use the <code>isCallerInRole(String roleName)</code> method instead.
*
* @param role The <code>java.security.Identity</code> of the role to be tested.
*
* @return True if the caller has the specified role.
*
* @deprecated Use boolean isCallerInRole(String roleName) instead.
*/
boolean isCallerInRole(Identity role);
/**
* Test if the caller has a given security role.
*
* @param roleName The name of the security role. The role must be one of
* the security roles that is defined in the deployment descriptor.
*
* @return True if the caller has the specified role.
*
* @exception IllegalStateException The Container throws the exception
* if the instance is not allowed to call this method.
*
* @since EJB 1.1
*/
boolean isCallerInRole(String roleName) throws IllegalStateException;
/**
* Obtain the transaction demarcation interface.
*
* Only enterprise beans with bean-managed transactions are allowed to
* to use the <code>UserTransaction</code> interface. As entity beans must always use
* container-managed transactions, only session beans or message-driven
* beans with bean-managed transactions are allowed to invoke this method.
*
* @return The <code>UserTransaction</code> interface that the enterprise bean
* instance can use for transaction demarcation.
*
* @exception IllegalStateException The Container throws the exception
* if the instance is not allowed to use the <code>UserTransaction</code> interface
* (i.e. the instance is of a bean with container-managed transactions).
*/
UserTransaction getUserTransaction() throws IllegalStateException;
/**
* Mark the current transaction for rollback. The transaction will become
* permanently marked for rollback. A transaction marked for rollback
* can never commit.
*
* Only enterprise beans with container-managed transactions are allowed
* to use this method.
*
* @exception IllegalStateException The Container throws the exception
* if the instance is not allowed to use this method (i.e. the
* instance is of a bean with bean-managed transactions).
*/
void setRollbackOnly() throws IllegalStateException;
/**
* Test if the transaction has been marked for rollback only. An enterprise
* bean instance can use this operation, for example, to test after an
* exception has been caught, whether it is fruitless to continue
* computation on behalf of the current transaction.
*
* Only enterprise beans with container-managed transactions are allowed
* to use this method.
*
* @return True if the current transaction is marked for rollback, false
* otherwise.
*
* @exception IllegalStateException The Container throws the exception
* if the instance is not allowed to use this method (i.e. the
* instance is of a bean with bean-managed transactions).
*/
boolean getRollbackOnly() throws IllegalStateException;
/**
* Get access to the EJB Timer Service.
*
* @exception IllegalStateException The Container throws the exception
* if the instance is not allowed to use this method (e.g. if the bean
* is a stateful session bean)
*
* @since EJB 2.1
*/
//TimerService getTimerService() throws IllegalStateException;
/**
* Lookup a resource within the <code>java:</code> namespace. Names referring to
* entries within the private component namespace can be passed as
* unqualified strings. In that case the lookup will be relative to
* <code>"java:comp/env/"</code>.
*
* For example, assuming an enterprise bean defines an <code>ejb-local-ref</code>
* with <code>ejb-ref-name</code> <code>"ejb/BarRef"</code> the following two
* calls to <code> EJBContext.lookup</code> are equivalent :
*
* <code>ejbContext.lookup("ejb/BarRef")</code>;
* <code>ejbContext.lookup("java:comp/env/ejb/BarRef")</code>;
*
* @param name Name of the entry
*
* @exception IllegalArgumentException The Container throws the exception
* if the given name does not match an entry within the component's
* environment.
*
* @since EJB 3.0
*/
Object lookup(String name) throws IllegalArgumentException;
/**
* The <code>getContextData</code> method enables a business method, lifecycle
* callback method, or timeout method to retrieve any interceptor/webservices context
* associated with its invocation.
*
* @return the context data that interceptor context associated with this invocation.
* If there is no context data, an empty <code>Map&#060;String,Object&#062;</code>
* object will be returned.
*
* @since EJB 3.1
*/
Map<String, Object> getContextData();
}

View File

@@ -0,0 +1,94 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The EJBException is thrown to report that the invoked
* business method or callback method could not be completed because
* of an unexpected error (e.g. the instance failed to open a database
* connection).
*
* @since EJB 1.1
*/
public class EJBException extends java.lang.RuntimeException {
private static final long serialVersionUID = 796770993296843510L;
/**
* Constructs an EJBException with no detail message.
*/
public EJBException() {
}
/**
* Constructs an EJBException with the specified
* detailed message.
*/
public EJBException(String message) {
super(message);
}
/**
* Constructs an EJBException that embeds the originally thrown exception.
*/
public EJBException(Exception ex) {
super(ex);
}
/**
* Constructs an EJBException that embeds the originally thrown exception
* with the specified detail message.
*/
public EJBException(String message, Exception ex) {
super(message, ex);
}
/**
* Obtain the exception that caused the EJBException to be thrown.
* It is recommended that the inherited Throwable.getCause() method
* be used to retrieve the cause instead of this method.
*/
public Exception getCausedByException() {
return (Exception) getCause();
}
}

View File

@@ -0,0 +1,120 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The EJBHome interface must be extended by all enterprise beans'
* remote home interfaces. An enterprise bean's remote home interface
* defines the methods that allow a remote client to create, find, and
* remove EJB objects.
*
* <p> The remote home interface is defined by the enterprise bean provider and
* implemented by the enterprise bean container.
* <p>
* Enterprise beans written to the EJB 3.0 and later APIs do not require
* a home interface.
*
* @since EJB 1.0
*/
public interface EJBHome extends java.rmi.Remote {
/**
* Remove an EJB object identified by its handle.
*
* @param handle the handle of the EJB object to be removed
*
* @exception RemoveException Thrown if the enterprise bean or
* the container does not allow the client to remove the object.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*/
void remove(Handle handle) throws RemoteException, RemoveException;
/**
* Remove an EJB object identified by its primary key.
*
* <p>This method can be used only for an entity bean. An attempt
* to call this method on a session bean will result in a RemoveException.
*
* <p><b>Note:</b> Support for entity beans is optional as of EJB 3.2.
*
* @param primaryKey the primary key of the EJB object to be removed
*
* @exception RemoveException Thrown if the enterprise bean or
* the container does not allow the client to remove the object.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*/
void remove(Object primaryKey) throws RemoteException, RemoveException;
/**
* Obtain the EJBMetaData interface for the enterprise bean. The
* EJBMetaData interface allows the client to obtain information about
* the enterprise bean.
*
* <p> The information obtainable via the EJBMetaData interface is
* intended to be used by tools.
*
* @return The enterprise Bean's EJBMetaData interface.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*/
EJBMetaData getEJBMetaData() throws RemoteException;
/**
* Obtain a handle for the remote home object. The handle can be used at
* later time to re-obtain a reference to the remote home object, possibly
* in a different Java Virtual Machine.
*
* @return A handle for the remote home object.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*
* @since EJB 1.1
*/
HomeHandle getHomeHandle() throws RemoteException;
}

View File

@@ -0,0 +1,80 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The EJBLocalHome interface must be extended by all enterprise
* beans' local home interfaces. An enterprise bean's local home
* interface defines the methods that allow local clients to create,
* find, and remove EJB objects.
*
* <p> The local home interface is defined by the enterprise bean provider
* and implemented by the enterprise bean container.
* <p>
* Enterprise beans written to the EJB 3.0 and later APIs do not require
* a local home interface.
*
* @since EJB 2.0
*/
public interface EJBLocalHome {
/**
* Remove an EJB object identified by its primary key.
*
* <p>This method can only be used by local clients of an entity
* bean. An attempt to call this method on a session bean will
* result in a RemoveException.
*
* <p><b>Note:</b> Support for entity beans is optional as of EJB 3.2.
*
* @param primaryKey the primary key of the EJB object to be removed
*
* @exception RemoveException Thrown if the enterprise bean or
* the container does not allow the client to remove the object.
*
* @exception EJBException Thrown when the method failed due to a
* system-level failure.
*
*/
void remove(Object primaryKey) throws RemoveException, EJBException;
}

View File

@@ -0,0 +1,117 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The EJBLocalObject interface must be extended by all enterprise beans' local
* interfaces. An enterprise bean's local interface provides the local client
* view of an EJB object. An enterprise bean's local interface defines
* the business methods callable by local clients.
*
* <p> The enterprise bean's local interface is defined by the enterprise
* bean provider and implemented by the enterprise bean container.
*
* <p>
* Enterprise beans written to the EJB 3.0 and later APIs do not require
* a local interface that extends the EJBLocalObject interface. A local
* business interface can be used instead.
*
* @since EJB 2.0
*/
public interface EJBLocalObject {
/**
* Obtain the enterprise bean's local home interface. The local home
* interface defines the enterprise bean's create, finder, remove,
* and home business methods that are available to local clients.
*
* @return A reference to the enterprise bean's local home interface.
*
* @exception EJBException Thrown when the method failed due to a
* system-level failure.
*
*/
public EJBLocalHome getEJBLocalHome() throws EJBException;
/**
* Obtain the primary key of the EJB local object.
*
* <p> This method can be called on an entity bean.
* An attempt to invoke this method on a session bean will result in
* an EJBException.
*
* <p><b>Note:</b> Support for entity beans is optional as of EJB 3.2.
*
* @return The EJB local object's primary key.
*
* @exception EJBException Thrown when the method failed due to a
* system-level failure or when invoked on a session bean.
*
*/
public Object getPrimaryKey() throws EJBException;
/**
* Remove the EJB local object.
*
* @exception RemoveException The enterprise bean or the container
* does not allow destruction of the object.
*
* @exception EJBException Thrown when the method failed due to a
* system-level failure.
*
*/
public void remove() throws RemoveException, EJBException;
/**
* Test if a given EJB local object is identical to the invoked EJB
* local object.
*
* @param obj An object to test for identity with the invoked object.
*
* @return True if the given EJB local object is identical to the
* invoked object, false otherwise.
*
*
* @exception EJBException Thrown when the method failed due to a
* system-level failure.
*
*/
boolean isIdentical(EJBLocalObject obj) throws EJBException;
}

View File

@@ -0,0 +1,101 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The EJBMetaData interface allows a client to obtain the enterprise bean's
* meta-data information.
*
* <p> The meta-data is intended for development tools used for
* building applications that use deployed enterprise beans, and for clients
* using a scripting language to access the enterprise bean.
*
* <p> Note that the EJBMetaData is not a remote interface. The class that
* implements this interface (this class is typically generated by container
* tools) must be serializable, and must be a valid RMI/IDL value type.
*
* @since EJB 1.0
*/
public interface EJBMetaData {
/**
* Obtain the remote home interface of the enterprise bean.
*
* @return the remote home interface of the enterprise bean.
*/
EJBHome getEJBHome();
/**
* Obtain the class object for the enterprise bean's remote home interface.
* @return the class object for the enterprise bean's remote home interface.
*/
Class getHomeInterfaceClass();
/**
* Obtain the class object for the enterprise bean's remote interface.
*
* @return the class object for the enterprise bean's remote interface.
*/
Class getRemoteInterfaceClass();
/**
* Obtain the class object for the enterprise bean's primary key class.
*
* @return the class object for the enterprise bean's primary key class.
*/
Class getPrimaryKeyClass();
/**
* Test if the enterprise bean's type is "session".
*
* @return True if the type of the enterprise bean is session bean.
*/
boolean isSession();
/**
* Test if the enterprise bean's type is "stateless session".
*
* @return True if the type of the enterprise Bean is stateless
* session.
*
* @since EJB 1.1
*/
boolean isStatelessSession();
}

View File

@@ -0,0 +1,128 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The EJBObject interface is extended by all enterprise beans' remote
* interfaces. An enterprise bean's remote interface provides the
* remote client view of an EJB object. An enterprise bean's remote
* interface defines the business methods callable by a remote client.
*
* <p> The remote interface must extend the javax.ejb.EJBObject
* interface, and define the enterprise bean specific business
* methods.
*
* <p> The enterprise bean's remote interface is defined by the enterprise
* bean provider and implemented by the enterprise bean container.
*
* <p>
* Enterprise beans written to the EJB 3.0 and later APIs do not require
* a remote interface that extends the EJBObject interface. A remote
* business interface can be used instead.
*
* @since EJB 1.0
*/
public interface EJBObject extends java.rmi.Remote {
/**
* Obtain the enterprise bean's remote home interface. The remote home
* interface defines the enterprise bean's create, finder, remove,
* and home business methods.
*
* @return A reference to the enterprise bean's home interface.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*/
public EJBHome getEJBHome() throws RemoteException;
/**
* Obtain the primary key of the EJB object.
*
* <p> This method can be called on an entity bean. An attempt to invoke
* this method on a session bean will result in RemoteException.
*
* <p><b>Note:</b> Support for entity beans is optional as of EJB 3.2.
*
* @return The EJB object's primary key.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure or when invoked on a session bean.
*/
public Object getPrimaryKey() throws RemoteException;
/**
* Remove the EJB object.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*
* @exception RemoveException The enterprise bean or the container
* does not allow destruction of the object.
*/
public void remove() throws RemoteException, RemoveException;
/**
* Obtain a handle for the EJB object. The handle can be used at later
* time to re-obtain a reference to the EJB object, possibly in a
* different Java Virtual Machine.
*
* @return A handle for the EJB object.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*/
public Handle getHandle() throws RemoteException;
/**
* Test if a given EJB object is identical to the invoked EJB object.
*
* @param obj An object to test for identity with the invoked object.
*
* @return True if the given EJB object is identical to the invoked object,
* false otherwise.
*
* @exception RemoteException Thrown when the method failed due to a
* system-level failure.
*/
boolean isIdentical(EJBObject obj) throws RemoteException;
}

View File

@@ -0,0 +1,54 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The EnterpriseBean interface is a common superinterface for the
* SessionBean, EntityBean and MessageDrivenBean interfaces.
*
* @see SessionBean
* @see MessageDrivenBean
* @see EntityBean
*
* @since EJB 1.0
*/
public interface EnterpriseBean extends java.io.Serializable {
}

View File

@@ -0,0 +1,220 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The EntityBean interface is implemented by every entity bean
* class. The container uses the EntityBean methods to notify the entity
* bean instances of the instance's life cycle events.
*
* <p>
* Applications written to the EJB 3.0 and later APIs should use the facilities
* of the Java Persistence API (<code>javax.persistence</code>) to model
* persistent entities.
*
* <p><b>Note:</b> Support for entity beans is optional as of EJB 3.2.
*
* @since EJB 1.0
*/
public interface EntityBean extends EnterpriseBean {
/**
* Set the associated entity context. The container invokes this method
* on an instance after the instance has been created.
*
* <p> This method is called in an unspecified transaction context.
*
* @param ctx An EntityContext interface for the instance. The instance
* should store the reference to the context in an instance variable.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void setEntityContext(EntityContext ctx) throws EJBException,
RemoteException;
/**
* Unset the associated entity context. The container calls this method
* before removing the instance.
*
* <p> This is the last method that the container invokes on the instance.
* The Java garbage collector will eventually invoke the finalize() method
* on the instance.
*
* <p> This method is called in an unspecified transaction context.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void unsetEntityContext() throws EJBException, RemoteException;
/**
* A container invokes this method before it removes the EJB object
* that is currently associated with the instance. This method
* is invoked when a client invokes a remove operation on the
* entity bean's home interface or the EJB object's remote interface.
* This method transitions the instance from the ready state to the pool
* of available instances.
*
* <p> This method is called in the transaction context of the remove
* operation.
*
* @exception RemoveException The enterprise Bean does not allow
* destruction of the object.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void ejbRemove() throws RemoveException, EJBException,
RemoteException;
/**
* A container invokes this method when the instance
* is taken out of the pool of available instances to become associated
* with a specific EJB object. This method transitions the instance to
* the ready state.
*
* <p> This method executes in an unspecified transaction context.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void ejbActivate() throws EJBException, RemoteException;
/**
* A container invokes this method on an instance before the instance
* becomes disassociated with a specific EJB object. After this method
* completes, the container will place the instance into the pool of
* available instances.
*
* <p> This method executes in an unspecified transaction context.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void ejbPassivate() throws EJBException, RemoteException;
/**
* A container invokes this method to instruct the
* instance to synchronize its state by loading it state from the
* underlying database.
*
* <p> This method always executes in the transaction context determined
* by the value of the transaction attribute in the deployment descriptor.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void ejbLoad() throws EJBException, RemoteException;
/**
* A container invokes this method to instruct the
* instance to synchronize its state by storing it to the underlying
* database.
*
* <p> This method always executes in the transaction context determined
* by the value of the transaction attribute in the deployment descriptor.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
public void ejbStore() throws EJBException, RemoteException;
}

View File

@@ -0,0 +1,62 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The Handle interface is implemented by all EJB object handles. A handle
* is an abstraction of a network reference to an EJB object. A handle is
* intended to be used as a "robust" persistent reference to an EJB object.
*
* @since EJB 1.0
*/
public interface Handle extends java.io.Serializable {
/**
* Obtain the EJB object reference represented by this handle.
*
* @return the EJB object reference represented by this handle.
*
* @exception RemoteException The EJB object could not be obtained
* because of a system-level failure.
*/
public EJBObject getEJBObject() throws RemoteException;
}

View File

@@ -0,0 +1,62 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The Handle interface is implemented by all EJB object handles. A handle
* is an abstraction of a network reference to an EJB object. A handle is
* intended to be used as a "robust" persistent reference to an EJB object.
*
* @since EJB 1.0
*/
public interface Handle extends java.io.Serializable {
/**
* Obtain the EJB object reference represented by this handle.
*
* @return the EJB object reference represented by this handle.
*
* @exception RemoteException The EJB object could not be obtained
* because of a system-level failure.
*/
public EJBObject getEJBObject() throws RemoteException;
}

View File

@@ -0,0 +1,62 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The HomeHandle interface is implemented by all home object handles. A handle
* is an abstraction of a network reference to a home object. A handle is
* intended to be used as a "robust" persistent reference to a home object.
*
* @since EJB 1.1
*/
public interface HomeHandle extends java.io.Serializable {
/**
* Obtain the home object represented by this handle.
*
* @return the home object represented by this handle.
*
* @exception RemoteException The home object could not be obtained
* because of a system-level failure.
*/
public EJBHome getEJBHome() throws RemoteException;
}

View File

@@ -0,0 +1,85 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
/**
* Declares the remote business interface(s) for a session bean.
* <p>
* The <code>Remote</code> annotation is applied to the session bean class or remote
* business interface to designate a remote business interface of the bean.
* <p>
* When used on an interface, designates that interface as a remote
* business interface. In this case, no <code>value</code> element should
* be provided.
* <p>
* The <code>Remote</code> annotation applies only to session beans and
* their interfaces.
*
* @since EJB 3.0
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Remote {
/**
* Specifies the remote business interface(s) of the bean. The <code>value</code>
* element is specified only when the annotation is applied to the bean class.
* It is only required to be specified if any of the following is true:
* <ul>
* <li>the bean class does not implement its remote business interface
* <li>at least one of the implemented interfaces is designated as a local interface
* <li>the bean class implements two or more interfaces and at
* least one of the implemented interfaces is designated
* as a remote business interface using <code>Remote</code> annotation on the interface,
* and at least one other interface (excluding <code>java.io.Serializable</code>,
* <code>java.io.Externalizable</code>, and any of the interfaces
* defined by the <code>javax.ejb</code> package) has no designation.
* </ul>
*/
Class[] value() default {};
}

View File

@@ -0,0 +1,68 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
/**
* The RemoveException is thrown at an attempt to remove an
* EJB object or local EJB object when the enterprise bean or the
* container does not allow the EJB object to be removed.
*
* @since EJB 1.0
*/
public class RemoveException extends java.lang.Exception {
private static final long serialVersionUID = -4581849053220157910L;
/**
* Constructs an RemoveException with no detail message.
*/
public RemoveException() {
}
/**
* Constructs an RemoveException with the specified
* detail message.
*/
public RemoveException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,144 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.rmi.RemoteException;
/**
* The SessionBean interface defines methods that the EJB container uses
* to notify a session bean instance of the instance's life cycle events.
* <p>
* As of EJB 3.0 it is no longer required that a session bean class
* implement this interface.
*
* @since EJB 1.0
*/
public interface SessionBean extends EnterpriseBean {
/**
* Set the associated session context. The container calls this method
* after the instance creation.
*
* <p> The session bean instance should store the reference to the
* context object in an instance variable.
*
* <p> This method is called with no transaction context.
*
* @param ctx A SessionContext interface for the instance.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for applications written
* for the EJB 1.0 specification. Enterprise beans written for the
* EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
void setSessionContext(SessionContext ctx) throws EJBException,
RemoteException;
/**
* A container invokes this method before it ends the life of the session
* object. This happens as a result of a client's invoking a remove
* operation, or when a container decides to terminate the session object
* after a timeout.
*
* <p> This method is called with no transaction context.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
void ejbRemove() throws EJBException, RemoteException;
/**
* The activate method is called when a stateful session bean instance is activated
* from its "passive" state. The instance should acquire any resource
* that it has released earlier in the <code>ejbPassivate</code> method.
*
* <p> This method is called with no transaction context.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
void ejbActivate() throws EJBException, RemoteException;
/**
* The passivate method is called before a stateful session bean instance enters
* the "passive" state. The instance should release any resources that
* it can re-acquire later in the <code>ejbActivate</code> method.
*
* <p> After the passivate method completes, the instance must be
* in a state that allows the container to use the Java Serialization
* protocol to externalize and store away the instance's state.
*
* <p> This method is called with no transaction context.
*
* @exception EJBException Thrown by the method to indicate a failure
* caused by a system-level error.
*
* @exception RemoteException This exception is defined in the method
* signature to provide backward compatibility for enterprise beans
* written for the EJB 1.0 specification. Enterprise beans written
* for the EJB 1.1 specification should throw the
* javax.ejb.EJBException instead of this exception.
* Enterprise beans written for the EJB2.0 and higher specifications
* must throw the javax.ejb.EJBException instead of this exception.
*/
void ejbPassivate() throws EJBException, RemoteException;
}

View File

@@ -0,0 +1,171 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.ejb;
import java.util.*;
import java.security.Identity;
//import javax.xml.rpc.handler.MessageContext;
/**
* The SessionContext interface provides access to the runtime session context
* that the container provides for a session bean instance. The
* container passes the SessionContext interface to an instance after the
* instance has been created. The session context remains associated with
* the instance for the lifetime of the instance.
*
* @since EJB 1.0
*/
public interface SessionContext extends EJBContext
{
/**
* Obtain a reference to the EJB local object that is
* associated with the instance.
*
* <p> An instance of a session bean can call this method at
* anytime between the <code>PostConstruct</code> or
* <code>ejbCreate</code> and <code>PreDestroy</code> or
* <code>ejbRemove</code> methods, including from within these
* methods.
*
* <p> An instance can use this method, for example, when it wants to
* pass a reference to itself in a method argument or result.
*
* @return The EJB local object currently associated with the instance.
*
* @exception IllegalStateException Thrown if the instance invokes this
* method while the instance is in a state that does not allow the
* instance to invoke this method, or if the instance does not have
* a local interface.
*
* @since EJB 2.0
*/
EJBLocalObject getEJBLocalObject() throws IllegalStateException;
/**
* Obtain a reference to the EJB object that is currently associated with
* the instance.
*
* <p> An instance of a session enterprise Bean can call this
* method at anytime between the <code>PostConstruct</code> or
* <code>ejbCreate</code> and the <code>PreDestroy</code> or
* <code>ejbRemove</code> methods, including from within these
* methods.
*
* <p> An instance can use this method, for example, when it wants to
* pass a reference to itself in a method argument or result.
*
* @return The EJB object currently associated with the instance.
*
* @exception IllegalStateException Thrown if the instance invokes this
* method while the instance is in a state that does not allow the
* instance to invoke this method, or if the instance does not have
* a remote interface.
*/
EJBObject getEJBObject() throws IllegalStateException;
/**
* Obtain a reference to the JAX-RPC MessageContext.
*
* <p> An instance of a stateless session bean can call this method
* from any business method invoked through its web service
* endpoint interface.
*
* <p><b>Note:</b> Support for web services invocations using JAX-RPC is optional as of EJB 3.2
*
* @return The MessageContext for this web service invocation.
*
* @exception IllegalStateException Thrown if this method is invoked
* while the instance is in a state that does not allow access
* to this method.
*
* @since EJB 2.1
*/
//MessageContext getMessageContext() throws IllegalStateException;
/**
* Obtain an object that can be used to invoke the current bean through
* a particular business interface view or its no-interface view.
*
* @param businessInterface One of the local business interfaces
* or remote business interfaces for this session bean.
* In addition, the bean class type can be used to acquire
* a reference to the bean's no-interface view.
*
* @return The business object corresponding to the given business
* interface or no-interface view.
*
* @exception IllegalStateException Thrown if invoked with a parameter
* that does not correspond to one of the beans' business interfaces
* or no-interface view.
*
* @since EJB 3.0
*/
<T> T getBusinessObject(Class<T> businessInterface) throws IllegalStateException;
/**
* Obtain the business interface or no-interface view type through which the
* current business method invocation was made.
*
* @exception IllegalStateException Thrown if this method is called
* and the bean has not been invoked through a business interface or
* no-interface view.
*
* @since EJB 3.0
*/
Class getInvokedBusinessInterface() throws IllegalStateException;
/**
* Check whether a client invoked the <code>cancel</code> method on the
* client <code>Future</code> object corresponding to the currently executing
* asynchronous business method.
*
* @return true if the client has invoked <code>Future.cancel</code> with a value of
* true for the <code>mayInterruptIfRunning</code> parameter.
*
* @exception IllegalStateException Thrown if not invoked from within an
* asynchronous business method invocation with return type
* <code>Future&#060;V&#062;</code>.
*
* @since EJB 3.1
*/
boolean wasCancelCalled() throws IllegalStateException;
}

View File

@@ -0,0 +1,63 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.transaction;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.SecurityException;
/**
* The UserTransaction interface defines the methods that allow an
* application to explicitly manage transaction boundaries.
*/
public interface UserTransaction {
void begin();
void commit();
void rollback();
void setRollbackOnly();
int getStatus();
void setTransactionTimeout(int seconds);
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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 javax.servlet;
/**
* This is the event class for notifications about changes to
* the servlet context of a web application.
* @see ServletContextListener
*
* @since Servlet 2.3
*/
public class ServletContextEvent extends java.util.EventObject {
/** Construct a ServletContextEvent from the given context.
*
* @param source - the ServletContext that is sending the event.
*/
public ServletContextEvent(ServletContext source) {
super(source);
}
/**
* Return the ServletContext that changed.
*
* @return the ServletContext that sent the event.
*/
public ServletContext getServletContext () {
return null;
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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 javax.servlet;
import java.util.EventListener;
/**
* Interface for receiving notification events about ServletContext
* lifecycle changes.
*
* <p>In order to receive these notification events, the implementation
* class must be either declared in the deployment descriptor of the web
* application, annotated with {@link javax.servlet.annotation.WebListener},
* or registered via one of the addListener methods defined on
* {@link ServletContext}.
*
* <p>Implementations of this interface are invoked at their
* {@link #contextInitialized} method in the order in which they have been
* declared, and at their {@link #contextDestroyed} method in reverse
* order.
*
* @see ServletContextEvent
*
* @since Servlet 2.3
*/
public interface ServletContextListener extends EventListener {
/**
* Receives notification that the web application initialization
* process is starting.
*
* <p>All ServletContextListeners are notified of context
* initialization before any filters or servlets in the web
* application are initialized.
*
* @param sce the ServletContextEvent containing the ServletContext
* that is being initialized
*
* @implSpec
* The default implementation takes no action.
*/
default public void contextInitialized(ServletContextEvent sce) {}
/**
* Receives notification that the ServletContext is about to be
* shut down.
*
* <p>All servlets and filters will have been destroyed before any
* ServletContextListeners are notified of context
* destruction.
*
* @param sce the ServletContextEvent containing the ServletContext
* that is being destroyed
*
* @implSpec
* The default implementation takes no action.
*/
default public void contextDestroyed(ServletContextEvent sce) {}
}