You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ad...@apache.org on 2007/01/12 08:30:12 UTC
svn commit: r495505 - in
/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb:
InternalErrorException.java core/CoreContext.java
Author: adc
Date: Thu Jan 11 23:30:11 2007
New Revision: 495505
URL: http://svn.apache.org/viewvc?view=rev&rev=495505
Log:
OPENEJB-94 cleaned up class and made first crack at getBusinessObject()
Added:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java (with props)
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java?view=auto&rev=495505
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java Thu Jan 11 23:30:11 2007
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb;
+
+/**
+ * This runtime exception should wrap odd runtime exceptions that would not
+ * make sense to the caller of the method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InternalErrorException extends RuntimeException {
+
+ public InternalErrorException() {
+ super();
+ }
+
+ public InternalErrorException(String message) {
+ super(message);
+ }
+
+ public InternalErrorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InternalErrorException(Throwable cause) {
+ super(cause);
+ }
+}
Propchange: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/InternalErrorException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java?view=diff&rev=495505&r1=495504&r2=495505
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java Thu Jan 11 23:30:11 2007
@@ -16,13 +16,7 @@
*/
package org.apache.openejb.core;
-import org.apache.openejb.DeploymentInfo;
-import org.apache.openejb.InterfaceType;
-import org.apache.openejb.RpcContainer;
-import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
-import org.apache.openejb.spi.SecurityService;
-import org.apache.openejb.util.proxy.ProxyManager;
-
+import java.util.List;
import javax.ejb.EJBHome;
import javax.ejb.EJBLocalHome;
import javax.ejb.EJBLocalObject;
@@ -32,7 +26,16 @@
import javax.naming.NamingException;
import javax.transaction.Status;
import javax.transaction.TransactionManager;
-import java.util.List;
+
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.InterfaceType;
+import org.apache.openejb.RpcContainer;
+import org.apache.openejb.InternalErrorException;
+import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
+import org.apache.openejb.core.ivm.IntraVmProxy;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.util.proxy.ProxyManager;
+
public abstract class CoreContext implements java.io.Serializable {
@@ -124,40 +127,32 @@
}
public Object getBusinessObject(Class interfce) {
- // TODO: This implementation isn't complete
ThreadContext threadContext = ThreadContext.getThreadContext();
DeploymentInfo di = threadContext.getDeploymentInfo();
-
InterfaceType interfaceType;
-
-
- Class businessLocalInterface = di.getBusinessLocalInterface();
- if (businessLocalInterface != null && businessLocalInterface.getName().equals(interfce.getName())) {
+ if (di.getBusinessLocalInterface() != null && di.getBusinessLocalInterface().getName().equals(interfce.getName())) {
interfaceType = InterfaceType.BUSINESS_LOCAL;
- } else
- if (di.getBusinessRemoteInterface() == null && di.getBusinessRemoteInterface().getName().equals(interfce.getName()))
- {
+ } else if (di.getBusinessRemoteInterface() != null && di.getBusinessRemoteInterface().getName().equals(interfce.getName())) {
interfaceType = InterfaceType.BUSINESS_REMOTE;
} else {
- // TODO: verify if this is the right exception
- throw new RuntimeException("Component has no such interface " + interfce.getName());
+ throw new IllegalArgumentException("Component has no such interface " + interfce.getName());
}
- Object newProxy = null;
+ Object newProxy;
try {
EjbObjectProxyHandler handler = newEjbObjectHandler((RpcContainer) di.getContainer(), threadContext.getPrimaryKey(), di.getDeploymentID(), interfaceType);
- Class[] interfaces = new Class[]{interfce, org.apache.openejb.core.ivm.IntraVmProxy.class};
+ Class[] interfaces = new Class[]{interfce, IntraVmProxy.class};
newProxy = ProxyManager.newProxyInstance(interfaces, handler);
} catch (IllegalAccessException iae) {
- throw new RuntimeException("Could not create IVM proxy for " + interfce.getName() + " interface");
+ throw new InternalErrorException("Could not create IVM proxy for " + interfce.getName() + " interface", iae);
}
return newProxy;
}
public EJBLocalHome getEJBLocalHome() {
ThreadContext threadContext = ThreadContext.getThreadContext();
- org.apache.openejb.core.CoreDeploymentInfo di = (org.apache.openejb.core.CoreDeploymentInfo) threadContext.getDeploymentInfo();
+ org.apache.openejb.core.CoreDeploymentInfo di = threadContext.getDeploymentInfo();
return di.getEJBLocalHome();
}
@@ -189,8 +184,7 @@
int status = getTransactionManager().getStatus();
if (status == Status.STATUS_MARKED_ROLLBACK || status == Status.STATUS_ROLLEDBACK)
return true;
- else
- if (status == Status.STATUS_NO_TRANSACTION)// this would be true for Supports tx attribute where no tx was propagated
+ else if (status == Status.STATUS_NO_TRANSACTION)// this would be true for Supports tx attribute where no tx was propagated
throw new IllegalStateException("No current transaction");
else
return false;
@@ -228,6 +222,7 @@
/**
* Lookup a resource within the component's private naming context.
+ *
* @param name - Name of the entry (relative to java:comp/env).
* @return The looked-up object.
* @see http://java.sun.com/javaee/5/docs/api/javax/ejb/EJBContext.html#lookup(java.lang.String)
@@ -239,7 +234,7 @@
try {
initialContext = new InitialContext();
- object = initialContext.lookup("java:comp/env/"+name);
+ object = initialContext.lookup("java:comp/env/" + name);
} catch (NamingException nex) {
throw new IllegalArgumentException(nex);
}