[Design of POJO Server] - Re: Integrating aop-mc-int bean metadata with AS5
by adrian@jboss.org
"kabir.khan(a)jboss.com" wrote :
| As part of PreInstallAction, AbstractScopeInfo.addMetaData() adds a new MemoryMetaDataLoader under:
|
| | [APPLICATION=vfszip:/Users/kabir/sourcecontrol/jboss-head/testsuite/output/lib/aop-scopeddependency-scoped.sar]
| |
| with this code
|
| | public void addMetaData(MutableMetaDataRepository repository, ControllerContext context)
| | {
| | this.repository = repository;
| | ScopeKey scope = getMutableScope();
| | MemoryMetaDataLoader mutable = new MemoryMetaDataLoader(scope);
| | repository.addMetaDataRetrieval(mutable);
| | addMetaData(repository, context, mutable);
| | }
| |
| This happens for every bean, and it overwrites the existing MetaDataContext that contained the aspect manager to use, so this no longer exists in the repository. Should this check if a retrieval exists already, and add to that instead?
|
Ok, so that's a bug. It shouldn't be overridding the mutable metadata context
if it already exists in the repository.
You're seeing it because you're using the wrong scope,
(the application instead of the instance scope) as the mutable scope,
but its obviously a problem if somebody wants to setup the instance
scope in the deployers.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4169533#4169533
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4169533
17 years, 8 months
[Design of POJO Server] - Re: Integrating aop-mc-int bean metadata with AS5
by adrian@jboss.org
"kabir.khan(a)jboss.com" wrote :
| Also, the call to scopeInfo.setMutableScope changes the scopeInfo.mutableScopeKey from
|
| | [INSTANCE=ScopedAlias_13_Factory$ScopedInterceptor]
| |
| to
|
| | [APPLICATION=vfszip:/Users/kabir/sourcecontrol/jboss-head/testsuite/output/lib/aop-scopeddependency-scoped.sar]
| |
|
You're main problem is that you are not using the BeanMetaDataDeployer
(or whatever code you copied from it) properly.
The BeanMetaDataDeployer is designed to be run against a Component deployment
which will have a mutable INSTANCE scope. You're running it against the top level
deployment which has a mutable scope of the whole APPLICATION.
AbstractDeploymentContext (i.e. an application/deployment)
|
| public ScopeKey getMutableScope()
| {
| if (mutableScope == null)
| {
| ScopeBuilder builder = getScopeBuilder(this);
| mutableScope = builder.getMutableDeploymentScope(this);
| }
| return mutableScope;
| }
|
ComponentDeploymentContext (i.e. a bean)
| public ScopeKey getMutableScope()
| {
| if (mutableScope == null)
| {
| ScopeBuilder builder = AbstractDeploymentContext.getScopeBuilder(this);
| mutableScope = builder.getMutableComponentScope(this);
| }
| return mutableScope;
| }
|
DefaultScopeBuilder
| public ScopeKey getMutableDeploymentScope(DeploymentContext context)
| {
| if (context == null)
| throw new IllegalArgumentException("Null context");
|
| if (context.isTopLevel())
| return new ScopeKey(CommonLevels.APPLICATION, context.getName());
| else
| return new ScopeKey(CommonLevels.DEPLOYMENT, context.getName());
| }
|
| ...
|
| public ScopeKey getMutableComponentScope(DeploymentContext context)
| {
| if (context == null)
| throw new IllegalArgumentException("Null context");
|
| return new ScopeKey(CommonLevels.INSTANCE, context.getName());
| }
|
Similar things happen for the runtime scope except there it builds a hierarchy
of scopes.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4169530#4169530
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4169530
17 years, 8 months
[Design of EJB 3.0] - Re: Which is the best place to write a test case for ejb3-te
by jaikiran
While testing the SessionContainer.invoke, i observed one other issue which was resulting in a NullPointerException:
| @Stateless
| @Local (MySLSBLocal.class)
| public class MySLSBean implements MySLSBLocal
| {
|
| public void printObject(Object obj)
| {
| // do nothing
|
| }
|
| }
Test case:
@Test
| public void testBeanMethodInvocationForNullParams() throws Throwable
| {
| // create the SLSB container
| this.sessionContainer = Utils.createSlsb(MySLSBean.class);
|
| // bind to JNDI
| Ejb3RegistrarLocator.locateRegistrar().bind(sessionContainer.getName(), sessionContainer);
|
| Context ctx = new InitialContext();
| // lookup the local bean
| MySLSBLocal local = (MySLSBLocal) ctx.lookup(getDefaultBusinessLocalJndiName(sessionContainer)
| );
|
| assertNotNull("Local bean is null",local);
|
| // pass null to the method
| local.printObject(null);
|
| }
|
|
This throws NPE:
| testBeanMethodInvocationForNullParams(org.jboss.ejb3.test.proxy.common.container.unit.SessionContainerTestCase) Time elapsed: 0.031 sec <<< ERROR!
| java.lang.NullPointerException
| at org.jboss.ejb3.test.proxy.common.container.SessionContainer.invoke(SessionContainer.java:182)
| at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:120)
| at $Proxy37.printObject(Unknown Source)
| at org.jboss.ejb3.test.proxy.common.container.unit.SessionContainerTestCase.testBeanMethodInvocationForNullParams(SessionContainerTestCase.java:149)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
| at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
| at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
| at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
| at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
| at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
| at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
| at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
| at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
| at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
| at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
| at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
| at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
| at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
| at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:165)
| at org.apache.maven.surefire.Surefire.run(Surefire.java:107)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:289)
| at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:993)
As part of fixing this and the earlier issue, i am changing the implementation of SessionContainer.invoke to do away with using Java Reflection APIs and instead use the toMethod() API of the SerializableMethod:
|
| Index: SessionContainer.java
| ===================================================================
| --- SessionContainer.java (revision 76706)
| +++ SessionContainer.java (working copy)
| @@ -25,9 +25,7 @@
| import java.lang.reflect.InvocationHandler;
| import java.lang.reflect.Method;
| import java.lang.reflect.Proxy;
| -import java.util.ArrayList;
| import java.util.HashSet;
| -import java.util.List;
| import java.util.Map;
| import java.util.Set;
|
| @@ -168,26 +166,9 @@
| */
| public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
| {
| - // Initialize
| - Class<?>[] argTypes = new Class<?>[]
| - {};
|
| - // Get the types from the arguments, if present
| - if (args != null)
| - {
| - List<Class<?>> types = new ArrayList<Class<?>>();
| - for (Object arg : args)
| - {
| - types.add(arg.getClass());
| - }
| - argTypes = types.toArray(new Class<?>[]
| - {});
| - }
| + Method m = method.toMethod(this.getClassLoader());
|
| - // Obtain the method for invocation
| - Method m = this.getClassLoader().loadClass(method.getDeclaringClassName()).getDeclaredMethod(method.getName(),
| - argTypes);
| -
| // Invoke on the bean
| return invokeBean(proxy, m, args);
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4169522#4169522
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4169522
17 years, 8 months