[jboss-cvs] JBossAS SVN: r81165 - in projects/ejb3/trunk/core/src: test/java/org/jboss/ejb3/core/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 17 07:13:39 EST 2008
Author: wolfc
Date: 2008-11-17 07:13:39 -0500 (Mon, 17 Nov 2008)
New Revision: 81165
Added:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyService.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceInterceptor.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/unit/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/unit/ServiceEJBContextTestCase.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
Log:
EJBTHREE-1593: service container start propagates exception, added EJBContext for service bean and fixed injection in interceptors
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java 2008-11-17 11:04:36 UTC (rev 81164)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -24,15 +24,14 @@
import javax.ejb.EJBContext;
import org.jboss.ejb3.session.SessionBeanContext;
-import org.jboss.ejb3.session.SessionContainer;
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
* @version $Revision$
*/
-public class ServiceBeanContext extends SessionBeanContext
+public class ServiceBeanContext extends SessionBeanContext<ServiceContainer>
{
- public ServiceBeanContext(SessionContainer container, Object bean)
+ public ServiceBeanContext(ServiceContainer container, Object bean)
{
super(container, bean);
}
@@ -45,7 +44,6 @@
@Override
public EJBContext getEJBContext()
{
- // TODO Auto-generated method stub
- return null;
+ return new ServiceSessionContextImpl(this);
}
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2008-11-17 11:04:36 UTC (rev 81164)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -305,7 +305,15 @@
catch (Exception e)
{
log.error("Encountered an error in start of " + this.getMetaData().getEjbName(), e);
- this.lockedStop();
+ try
+ {
+ lockedStop();
+ }
+ catch(Exception stopEx)
+ {
+ log.error("Error during forced container stop", stopEx);
+ }
+ throw e;
}
}
@@ -548,7 +556,15 @@
if (beanContext == null)
{
beanContext = createBeanContext();
- beanContext.initialiseInterceptorInstances();
+ pushEnc();
+ try
+ {
+ beanContext.initialiseInterceptorInstances();
+ }
+ finally
+ {
+ popEnc();
+ }
}
}
}
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.service;
+
+import org.jboss.ejb3.EJBContextImpl;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ServiceSessionContextImpl extends EJBContextImpl<ServiceContainer, ServiceBeanContext>
+{
+ /**
+ * @param beanContext
+ */
+ protected ServiceSessionContextImpl(ServiceBeanContext beanContext)
+ {
+ super(beanContext);
+ }
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyService.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyService.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyService.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree1593;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyService
+{
+ void testEjbContext();
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceBean.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree1593;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBContext;
+import javax.ejb.Local;
+import javax.interceptor.Interceptors;
+
+import org.jboss.ejb3.annotation.Service;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Service
+ at Local(MyService.class)
+ at Interceptors(MyServiceInterceptor.class)
+public class MyServiceBean implements MyService
+{
+ @Resource
+ private EJBContext ctx;
+
+ public void testEjbContext()
+ {
+ if(ctx == null)
+ throw new IllegalStateException("ctx was not injected");
+ }
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceInterceptor.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/MyServiceInterceptor.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree1593;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBContext;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MyServiceInterceptor
+{
+ @Resource
+ private EJBContext ctx;
+
+ public Object intercept(InvocationContext ctx) throws Exception
+ {
+ if(ctx == null)
+ throw new IllegalStateException("ctx was not injected");
+ return ctx.proceed();
+ }
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/unit/ServiceEJBContextTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/unit/ServiceEJBContextTestCase.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1593/unit/ServiceEJBContextTestCase.java 2008-11-17 12:13:39 UTC (rev 81165)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree1593.unit;
+
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.ejbthree1593.MyService;
+import org.jboss.ejb3.core.test.ejbthree1593.MyServiceBean;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ServiceEJBContextTestCase extends AbstractEJB3TestCase
+{
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ AbstractEJB3TestCase.beforeClass();
+
+ deploySessionEjb(MyServiceBean.class);
+ }
+
+ @Test
+ public void testInjection() throws Exception
+ {
+ MyService service = lookup("MyServiceBean/local", MyService.class);
+ service.testEjbContext();
+ }
+}
More information about the jboss-cvs-commits
mailing list