Skip to content

Commit

Permalink
More refactoring, mostly formatting again.
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms committed Jun 5, 2022
1 parent f35ebd0 commit ca93d4a
Show file tree
Hide file tree
Showing 24 changed files with 960 additions and 1,197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void registerRuntimeInterceptor(Object interceptorInstance, BundleDescrip
for (ManagedBeanDescriptor managedBeanDescriptor : bundle.getManagedBeans()) {
JavaEEInterceptorBuilder interceptorBuilder = (JavaEEInterceptorBuilder) managedBeanDescriptor.getInterceptorBuilder();

interceptorBuilder.addRuntimeInterceptor(managedBeanDescriptor.getInterceptorBuilder());
interceptorBuilder.addRuntimeInterceptor(interceptorInstance);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -18,24 +19,24 @@

import java.util.concurrent.atomic.AtomicInteger;

import org.glassfish.ejb.deployment.descriptor.EjbDescriptor;

import com.sun.ejb.ComponentContext;
import com.sun.ejb.EjbInvocation;
import com.sun.enterprise.security.SecurityManager;
import org.glassfish.ejb.deployment.descriptor.EjbDescriptor;

/**
* @author Mahesh Kannan
*/
public class BMCSingletonContainer
extends AbstractSingletonContainer {
public class BMCSingletonContainer extends AbstractSingletonContainer {

private AtomicInteger invCount = new AtomicInteger(0);

public BMCSingletonContainer(EjbDescriptor desc, ClassLoader cl, SecurityManager sm)
throws Exception {
public BMCSingletonContainer(EjbDescriptor desc, ClassLoader cl, SecurityManager sm) throws Exception {
super(desc, cl, sm);
}

@Override
protected ComponentContext _getContext(EjbInvocation inv) {
checkInit();

Expand All @@ -44,10 +45,11 @@ protected ComponentContext _getContext(EjbInvocation inv) {
((SingletonContextImpl) singletonCtx).setState(EJBContextImpl.BeanState.INVOKING);
}

//For now return this as we support only BMC
// For now return this as we support only BMC
return singletonCtx;
}

@Override
public void releaseContext(EjbInvocation inv) {
synchronized (invCount) {
int val = invCount.decrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -17,29 +18,20 @@
package com.sun.ejb.containers.interceptors;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;

import java.lang.reflect.Method;

/**
* Concrete InvocationContext implementation passed to callback methods
* defined in interceptor classes.
* Concrete InvocationContext implementation passed to callback methods defined in interceptor classes.
*/
public class AroundInvokeInvocationContext extends CallbackInvocationContext
implements InterceptorManager.AroundInvokeContext {
public class AroundInvokeInvocationContext extends CallbackInvocationContext implements InterceptorManager.AroundInvokeContext {

private Method method;
private int interceptorIndex = 0;
private InterceptorManager.InterceptorChain chain;
private Object[] parameters;


public AroundInvokeInvocationContext(Object targetObjectInstance,
Object[] interceptorInstances,
InterceptorManager.InterceptorChain chain,
Method m,
Object[] params
) {
public AroundInvokeInvocationContext(Object targetObjectInstance, Object[] interceptorInstances, InterceptorManager.InterceptorChain chain, Method m, Object[] params) {
super(targetObjectInstance, interceptorInstances, null);
method = m;
this.chain = chain;
Expand All @@ -57,9 +49,7 @@ public Method getMethod() {
}

@Override
public Object proceed()
throws Exception
{
public Object proceed() throws Exception {
try {
interceptorIndex++;
return chain.invokeNext(interceptorIndex, this);
Expand All @@ -84,28 +74,19 @@ public void setParameters(Object[] params) {

}


/**
* Called from Interceptor Chain to invoke the actual bean method.
* This method must throw any exception from the bean method *as is*,
* without being wrapped in an InvocationTargetException. The exception
* thrown from this method will be propagated through the application's
* interceptor code, so it must not be changed in order for any exception
* handling logic in that code to function properly.
*/
public Object invokeBeanMethod() throws Throwable {

* Called from Interceptor Chain to invoke the actual bean method. This method must throw any exception from the bean
* method *as is*, without being wrapped in an InvocationTargetException. The exception thrown from this method will be
* propagated through the application's interceptor code, so it must not be changed in order for any exception handling
* logic in that code to function properly.
*/
@Override
public Object invokeBeanMethod() throws Throwable {
try {

return method.invoke(getTarget(), parameters);

} catch(InvocationTargetException ite) {
} catch (InvocationTargetException ite) {
throw ite.getCause();
}

}



}

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,8 +20,7 @@
import java.lang.reflect.Method;

/**
* @author Mahesh Kannan
* Date: Mar 10, 2008
* @author Mahesh Kannan Date: Mar 10, 2008
*/
class CallbackChainImpl {

Expand All @@ -33,14 +33,12 @@ class CallbackChainImpl {
this.size = (interceptors == null) ? 0 : interceptors.length;

// set invocation method if there is one on the bean class
if (size > 0 && interceptors[size-1].isBeanCallback()) {
method = interceptors[size-1].method;
if (size > 0 && interceptors[size - 1].isBeanCallback()) {
method = interceptors[size - 1].method;
}
}

public Object invokeNext(int index, CallbackInvocationContext invContext)
throws Throwable {

public Object invokeNext(int index, CallbackInvocationContext invContext) throws Throwable {
invContext.method = method;
Object result = null;
if (index < size) {
Expand All @@ -52,6 +50,7 @@ public Object invokeNext(int index, CallbackInvocationContext invContext)
return result;
}

@Override
public String toString() {
StringBuilder bldr = new StringBuilder("CallbackInterceptorChainImpl");
for (CallbackInterceptor inter : interceptors) {
Expand All @@ -63,15 +62,15 @@ public String toString() {

/**
* Prepend an interceptor to an existing callback chain.
*
* @param interceptor
*/
public void prependInterceptor(CallbackInterceptor interceptor) {

size++;

CallbackInterceptor[] newArray = new CallbackInterceptor[size];
newArray[0] = interceptor;
for(int i = 1; i < size; i++) {
for (int i = 1; i < size; i++) {
newArray[i] = interceptors[i - 1];
}

Expand Down

0 comments on commit ca93d4a

Please sign in to comment.