You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2010/07/22 09:06:40 UTC
svn commit: r966519 [2/2] - in /openejb/branches/openejb-jcdi/container:
openejb-core/src/main/java/org/apache/openejb/assembler/classic/
openejb-core/src/main/java/org/apache/openejb/cdi/
openejb-core/src/main/java/org/apache/openejb/config/ openejb-c...
Modified: openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java?rev=966519&r1=966518&r2=966519&view=diff
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java (original)
+++ openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java Thu Jul 22 07:06:39 2010
@@ -1057,11 +1057,16 @@ public class CoreDeploymentInfo extends
final Class clazz = interceptorInstance.getData().getInterceptorClass();
interceptorInstances.put(clazz.getName(), interceptorInstance.getInterceptor());
}
+ OWBInjector beanInjector = null;
+
+ try {
+ //Inject Cdi dependencies to bean instance
+ beanInjector = new OWBInjector();
+ beanInjector.inject(bean);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- //Inject Cdi dependencies to bean instance
- OWBInjector beanInjector = new OWBInjector();
- beanInjector.inject(bean);
-
this.cdiInjectors.add(beanInjector);
for (InterceptorData interceptorData : this.getInstanceScopedInterceptors()) {
Modified: openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/managed/Instance.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/managed/Instance.java?rev=966519&r1=966518&r2=966519&view=diff
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/managed/Instance.java (original)
+++ openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/managed/Instance.java Thu Jul 22 07:06:39 2010
@@ -156,6 +156,8 @@ public class Instance implements Seriali
interceptors.put(e.getKey(), bean);
} else if (!(e.getValue() instanceof Serializable)) {
interceptors.put(e.getKey(), new PojoSerialization(e.getValue()));
+ } else {
+ interceptors.put(e.getKey(), e.getValue());
}
}
Modified: openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/Instance.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/Instance.java?rev=966519&r1=966518&r2=966519&view=diff
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/Instance.java (original)
+++ openejb/branches/openejb-jcdi/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/Instance.java Thu Jul 22 07:06:39 2010
@@ -156,6 +156,8 @@ public class Instance implements Seriali
interceptors.put(e.getKey(), bean);
} else if (!(e.getValue() instanceof Serializable)) {
interceptors.put(e.getKey(), new PojoSerialization(e.getValue()));
+ } else {
+ interceptors.put(e.getKey(), e.getValue());
}
}
Copied: openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/CdiDecoratorTest.java (from r964308, openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/decorator/CdiDecoratorTest.java)
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/CdiDecoratorTest.java?p2=openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/CdiDecoratorTest.java&p1=openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/decorator/CdiDecoratorTest.java&r1=964308&r2=966519&rev=966519&view=diff
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/decorator/CdiDecoratorTest.java (original)
+++ openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/CdiDecoratorTest.java Thu Jul 22 07:06:39 2010
@@ -14,16 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.openejb.cdi.decorator;
-
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+package org.apache.openejb.cdi;
+import junit.framework.TestCase;
import org.apache.openejb.assembler.classic.Assembler;
-import org.apache.openejb.assembler.classic.EjbJarInfo;
import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
import org.apache.openejb.assembler.classic.SecurityServiceInfo;
import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
@@ -32,22 +26,40 @@ import org.apache.openejb.cdi.CdiAppScan
import org.apache.openejb.config.ConfigurationFactory;
import org.apache.openejb.config.EjbModule;
import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.jee.Beans;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.StatelessBean;
import org.junit.Before;
-import junit.framework.TestCase;
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+import javax.inject.Qualifier;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import javax.interceptor.InvocationContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Properties;
@SuppressWarnings("deprecation")
-public class CdiDecoratorTest extends TestCase{
+public class CdiDecoratorTest extends TestCase {
private InitialContext ctx;
-
+
@Before
public void setUp() throws Exception {
-
- CdiAppScannerService.BEANS_XML_LOCATION = "org/apache/openejb/cdi/decorator/META-INF/beans.xml";
- CdiAppScannerService.APPEND_PACKAGE_NAME = "org.apache.openejb.cdi.decorator";
+
+ CdiAppScannerService.BEANS_XML_LOCATION = "org/apache/openejb/cdi/decorator/META-INF/beans.xml";
+ CdiAppScannerService.APPEND_PACKAGE_NAME = "org.apache.openejb.cdi.decorator";
ConfigurationFactory config = new ConfigurationFactory();
Assembler assembler = new Assembler();
@@ -57,50 +69,134 @@ public class CdiDecoratorTest extends Te
assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
- EjbModule ejbModule = buildTestApp();
- EjbJarInfo ejbJar = config.configureApplication(ejbModule);
-
- assertNotNull(ejbJar);
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new StatelessBean(HelloStateless.class));
+ ejbJar.addEnterpriseBean(new StatelessBean(LocalHello.class));
+
+ Beans beans = new Beans();
+ beans.addInterceptor(HelloLocalInterceptor.class);
+ beans.addDecorator(HelloDecorator.class);
+ beans.addManagedClass(HelloCdiBean.class);
+
+ EjbModule module = new EjbModule(ejbJar);
+ module.setBeans(beans);
- assembler.createApplication(ejbJar);
+ assembler.createApplication(config.configureApplication(module));
Properties properties = new Properties(System.getProperties());
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
ctx = new InitialContext(properties);
}
-
- public void testSimple(){
- try {
- IHello hello = (IHello)ctx.lookup("HelloLocal");
- hello.hello();
-
- assertTrue(HelloCdiBean.RUN);
- assertTrue(LocalHello.RUN);
- assertTrue(Hello.RUN);
- assertTrue(HelloLocalInterceptor.RUN);
- assertTrue(HelloDecorator.RUN);
-
- } catch (NamingException e) {
- e.printStackTrace();
- }
-
-
+
+ public void testSimple() {
+ try {
+ Hello hello = (Hello) ctx.lookup("HelloStatelessLocal");
+ hello.hello();
+
+ assertTrue(HelloCdiBean.RUN);
+ assertTrue(LocalHello.RUN);
+ assertTrue(HelloStateless.RUN);
+ assertTrue(HelloLocalInterceptor.RUN);
+ assertTrue(HelloDecorator.RUN);
+
+ } catch (NamingException e) {
+ e.printStackTrace();
+ }
}
-
- public EjbModule buildTestApp() throws Exception {
- EjbJar ejbJar = new EjbJar();
- ejbJar.setId(this.getClass().getName());
-
- ejbJar.addEnterpriseBean(new StatelessBean(Hello.class));
- ejbJar.addEnterpriseBean(new StatelessBean(LocalHello.class));
- EjbModule module = new EjbModule(ejbJar);
-
- //Just for marker!
- module.getAltDDs().put("beans.xml", null);
+
+
+ public static interface Hello {
+ public void hello();
+ }
+
+ @InterceptorBinding
+ @Target(value = {ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface LocalEjbInterceptorBinding {
+
+ }
+
+ @Qualifier
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
+ public static @interface LocalEjbQualifier {
+
+ }
+
+ @Stateless
+ public static class HelloStateless implements Hello {
+
+ @Inject
+ private HelloCdiBean cdiBean;
+ public static boolean RUN = false;
+
+ @Override
+ public void hello() {
+ RUN = true;
+ System.out.println("In EJB : " + HelloStateless.class.getName());
+ cdiBean.sayHelloWorld();
+ }
+ }
+
+ public static class HelloCdiBean {
+
+ @Inject
+ @LocalEjbQualifier
+ private Hello helloEjb;
- return module;
+ public static boolean RUN = false;
+
+ public void sayHelloWorld() {
+ RUN = true;
+ System.out.println("In Managed Bean : " + HelloCdiBean.class.getName());
+ this.helloEjb.hello();
+ }
+ }
+
+ @Decorator
+ public static class HelloDecorator implements Hello {
+
+ public static boolean RUN = false;
+
+ @Inject
+ @Delegate
+ @LocalEjbQualifier
+ private Hello hello;
+
+ @Override
+ public void hello() {
+ System.out.println("In CDI Style Decorator : " + HelloDecorator.class.getName());
+ RUN = true;
+ this.hello.hello();
+ }
+ }
+
+ @Interceptor
+ @LocalEjbInterceptorBinding
+ public static class HelloLocalInterceptor {
+
+ public static boolean RUN = false;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception {
+ System.out.println("In CDI Style Interceptor : " + HelloLocalInterceptor.class.getName());
+ RUN = true;
+ return ctx.proceed();
+ }
+ }
+
+ @LocalBean
+ @LocalEjbQualifier
+ @LocalEjbInterceptorBinding
+ public static class LocalHello implements Hello {
+
+ public static boolean RUN = false;
+
+ @Override
+ public void hello() {
+ System.out.println("In EJB : " + LocalHello.class.getName());
+ RUN = true;
+ }
}
-
-
}
Propchange: openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/CdiDecoratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/SimpleCdiTest.java (from r964308, openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/simple/SimpleCdiTest.java)
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/SimpleCdiTest.java?p2=openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/SimpleCdiTest.java&p1=openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/simple/SimpleCdiTest.java&r1=964308&r2=966519&rev=966519&view=diff
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/simple/SimpleCdiTest.java (original)
+++ openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/SimpleCdiTest.java Thu Jul 22 07:06:39 2010
@@ -14,89 +14,213 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.openejb.cdi.simple;
-
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+package org.apache.openejb.cdi;
+import junit.framework.TestCase;
import org.apache.openejb.assembler.classic.Assembler;
-import org.apache.openejb.assembler.classic.EjbJarInfo;
-import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
import org.apache.openejb.assembler.classic.SecurityServiceInfo;
-import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
import org.apache.openejb.assembler.classic.TransactionServiceInfo;
-import org.apache.openejb.cdi.CdiAppScannerService;
import org.apache.openejb.config.ConfigurationFactory;
import org.apache.openejb.config.EjbModule;
import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.jee.Beans;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.StatelessBean;
import org.junit.Before;
-import junit.framework.TestCase;
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Qualifier;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.Serializable;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Properties;
@SuppressWarnings("deprecation")
-public class SimpleCdiTest extends TestCase{
+public class SimpleCdiTest extends TestCase {
private InitialContext ctx;
-
+
@Before
public void setUp() throws Exception {
-
- CdiAppScannerService.BEANS_XML_LOCATION = "org/apache/openejb/cdi/simple/META-INF/beans.xml";
- CdiAppScannerService.APPEND_PACKAGE_NAME = "org.apache.openejb.cdi.simple";
+
ConfigurationFactory config = new ConfigurationFactory();
Assembler assembler = new Assembler();
- assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
- assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new StatelessBean(Echo.class));
+
+ Beans beans = new Beans();
+ beans.addInterceptor(EchoInterceptor.class);
+ beans.addDecorator(EchoDecorator.class);
+ beans.addManagedClass(SimpleModel.class);
+ beans.addManagedClass(ProducesEjbInjector.class);
- EjbModule ejbModule = buildTestApp();
- EjbJarInfo ejbJar = config.configureApplication(ejbModule);
-
- assertNotNull(ejbJar);
+ EjbModule module = new EjbModule(ejbJar);
+ module.setBeans(beans);
- assembler.createApplication(ejbJar);
+ assembler.createApplication(config.configureApplication(module));
Properties properties = new Properties(System.getProperties());
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
ctx = new InitialContext(properties);
}
-
- public void testSimple(){
- try {
- EchoLocal echo = (EchoLocal)ctx.lookup("EchoLocal");
- String result = echo.echo("Gurkan");
- assertEquals("Gurkan", result);
-
- assertTrue(EchoInterceptor.RUN);
- assertTrue(NormalEjbInterceptor.RUN);
- assertTrue(NormalEjbInterceptor.INJECTED);
-
- } catch (NamingException e) {
- e.printStackTrace();
- }
-
-
+
+ public void testSimple() {
+ try {
+ EchoLocal echo = (EchoLocal) ctx.lookup("EchoLocal");
+ String result = echo.echo("Gurkan");
+ assertEquals("Gurkan", result);
+
+ assertTrue(EchoInterceptor.RUN);
+ assertTrue(NormalEjbInterceptor.RUN);
+ assertTrue(NormalEjbInterceptor.INJECTED);
+
+ } catch (NamingException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @InterceptorBinding
+ @Target(value = {ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface EchoInterceptorBinding {
+
}
-
- public EjbModule buildTestApp() throws Exception {
- EjbJar ejbJar = new EjbJar();
- ejbJar.setId(this.getClass().getName());
-
- ejbJar.addEnterpriseBean(new StatelessBean(Echo.class));
- EjbModule module = new EjbModule(ejbJar);
- module.getAltDDs().put("beans.xml", SimpleCdiTest.class.getClassLoader().getResource("cdi/beans.xml"));
-
-
- return module;
+
+ @Interceptor
+ @EchoInterceptorBinding
+ public static class EchoInterceptor implements Serializable {
+
+ public static boolean RUN = false;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext context) throws Exception {
+ RUN = true;
+ return context.proceed();
+ }
+ }
+
+ @Stateless
+ @EchoInterceptorBinding
+ @Interceptors(value = {NormalEjbInterceptor.class})
+ public static class Echo implements EchoLocal {
+
+ @Inject
+ private SimpleModel model;
+
+ @Inject
+ private ProducesEjbInjector injector;
+
+ @Override
+ public String echo(String echo) {
+ assertNotNull(model);
+ return echo;
+ }
+
+ }
+
+ @Local
+ public static interface EchoLocal {
+ public String echo(String echo);
+ }
+
+ public static class ProducesEjbInjector {
+
+ @Inject
+ @EchoEjbQualifier
+ private EchoLocal echo;
+
+ public EchoLocal getEcho() {
+ return echo;
+ }
+
+ public void setEcho(EchoLocal echo) {
+ this.echo = echo;
+ }
+ }
+
+ public static class NormalEjbInterceptor implements Serializable {
+
+ public static boolean RUN = false;
+ public static boolean INJECTED = false;
+
+ @Inject
+ private SimpleModel injection;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext context) throws Exception {
+ RUN = true;
+ if (injection != null) {
+ INJECTED = true;
+ }
+
+ return context.proceed();
+ }
+ }
+
+ @Qualifier
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(value = {ElementType.FIELD})
+ public static @interface EchoEjbQualifier {
+
+ }
+
+ public static class SimpleModel implements Serializable {
+
+ @EJB
+ private EchoLocal echoLocal;
+
+ @Produces
+ @EchoEjbQualifier
+ @EJB
+ private EchoLocal local2ViaProduce;
+
+ public EchoLocal getLocal2ViaProduce() {
+ return local2ViaProduce;
+ }
+
+ public void setLocal2ViaProduce(EchoLocal local2ViaProduce) {
+ this.local2ViaProduce = local2ViaProduce;
+ }
+
+ public EchoLocal getEchoLocal() {
+ return echoLocal;
+ }
+
+ public void setEchoLocal(EchoLocal echoLocal) {
+ this.echoLocal = echoLocal;
+ }
+ }
+
+ @Decorator
+ public static class EchoDecorator implements EchoLocal {
+
+ @Inject
+ @Delegate
+ private EchoLocal local;
+
+ @Override
+ public String echo(String echo) {
+ return local.echo(echo);
+ }
}
-
-
}
Propchange: openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/cdi/SimpleCdiTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/branches/openejb-jcdi/container/openejb-jee/src/main/java/org/apache/openejb/jee/Beans.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-jee/src/main/java/org/apache/openejb/jee/Beans.java?rev=966519&view=auto
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-jee/src/main/java/org/apache/openejb/jee/Beans.java (added)
+++ openejb/branches/openejb-jcdi/container/openejb-jee/src/main/java/org/apache/openejb/jee/Beans.java Thu Jul 22 07:06:39 2010
@@ -0,0 +1,195 @@
+/**
+ * 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.jee;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <all>
+ * <element ref="{http://java.sun.com/xml/ns/javaee}interceptors" minOccurs="0"/>
+ * <element ref="{http://java.sun.com/xml/ns/javaee}decorators" minOccurs="0"/>
+ * <element ref="{http://java.sun.com/xml/ns/javaee}alternatives" minOccurs="0"/>
+ * </all>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+
+})
+@XmlRootElement(name = "beans")
+public class Beans {
+
+ @XmlTransient
+ private final List<String> managedClasses = new ArrayList<String>();
+
+ @XmlElementWrapper(name = "interceptors")
+ @XmlElement(name = "class")
+ protected List<String> interceptors;
+
+ @XmlElementWrapper(name = "decorators")
+ @XmlElement(name = "class")
+ protected List<String> decorators;
+
+ protected Alternatives alternatives;
+
+ public List<String> getManagedClasses() {
+ return managedClasses;
+ }
+
+ public void addManagedClass(String className) {
+ managedClasses.add(className);
+ }
+
+ public void addManagedClass(Class clazz) {
+ addManagedClass(clazz.getName());
+ }
+
+ public List<String> getInterceptors() {
+ if (interceptors == null) {
+ interceptors = new ArrayList<String>();
+ }
+ return interceptors;
+ }
+
+ public void addInterceptor(String className) {
+ getInterceptors().add(className);
+ }
+
+ public void addInterceptor(Class clazz) {
+ addInterceptor(clazz.getName());
+ }
+
+ public List<String> getDecorators() {
+ if (decorators == null) {
+ decorators = new ArrayList<String>();
+ }
+ return decorators;
+ }
+
+ public void addDecorator(String className) {
+ getDecorators().add(className);
+ }
+
+ public void addDecorator(Class clazz) {
+ addDecorator(clazz.getName());
+ }
+
+ public List<String> getAlternativeClasses() {
+ return getAlternatives().getClasses();
+ }
+
+ public void addAlternativeClass(String className) {
+ getAlternativeClasses().add(className);
+ }
+
+ public void addAlternativeClass(Class clazz) {
+ addAlternativeClass(clazz.getName());
+ }
+
+ public List<String> getAlternativeStereotypes() {
+ return getAlternatives().getStereotypes();
+ }
+
+ public void addAlternativeStereotype(String className) {
+ getAlternativeStereotypes().add(className);
+ }
+
+ public void addAlternativeStereotype(Class clazz) {
+ addAlternativeStereotype(clazz.getName());
+ }
+
+ /**
+ * Gets the value of the alternatives property.
+ *
+ * @return possible object is
+ * {@link Alternatives }
+ */
+ private Alternatives getAlternatives() {
+ if (alternatives == null) {
+ alternatives = new Alternatives();
+ }
+ return alternatives;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element name="class" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="stereotype" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "classes",
+ "stereotypes"
+ })
+ @XmlRootElement(name = "alternatives")
+ public static class Alternatives {
+
+ @XmlElement(name = "class")
+ protected List<String> classes;
+
+ @XmlElement(name = "stereotype")
+ protected List<String> stereotypes;
+
+ public List<String> getClasses() {
+ if (classes == null) {
+ classes = new ArrayList<String>();
+ }
+ return classes;
+ }
+
+ public List<String> getStereotypes() {
+ if (stereotypes == null) {
+ stereotypes = new ArrayList<String>();
+ }
+ return stereotypes;
+ }
+ }
+}
Propchange: openejb/branches/openejb-jcdi/container/openejb-jee/src/main/java/org/apache/openejb/jee/Beans.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openejb/branches/openejb-jcdi/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java?rev=966519&r1=966518&r2=966519&view=diff
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java (original)
+++ openejb/branches/openejb-jcdi/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java Thu Jul 22 07:06:39 2010
@@ -225,6 +225,10 @@ public class JeeTest extends TestCase {
marshalAndUnmarshal(Connector.class, "connector-1.6-example.xml", null);
}
+ public void testBeans10() throws Exception {
+ marshalAndUnmarshal(Beans.class, "beans-1.0-example.xml", null);
+ }
+
public static <T> T marshalAndUnmarshal(Class<T> type, String sourceXmlFile, String expectedXmlFile) throws Exception {
InputStream in = JeeTest.class.getClassLoader().getResourceAsStream(sourceXmlFile);
T object = (T)JaxbJavaee.unmarshalJavaee(type, in);
Added: openejb/branches/openejb-jcdi/container/openejb-jee/src/test/resources/beans-1.0-example.xml
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-jcdi/container/openejb-jee/src/test/resources/beans-1.0-example.xml?rev=966519&view=auto
==============================================================================
--- openejb/branches/openejb-jcdi/container/openejb-jee/src/test/resources/beans-1.0-example.xml (added)
+++ openejb/branches/openejb-jcdi/container/openejb-jee/src/test/resources/beans-1.0-example.xml Thu Jul 22 07:06:39 2010
@@ -0,0 +1,20 @@
+<beans>
+ <interceptors>
+ <class>org.foo.One</class>
+ <class>org.foo.Two</class>
+ <class>org.foo.Three</class>
+ </interceptors>
+ <decorators>
+ <class>org.foo.Four</class>
+ <class>org.foo.Five</class>
+ <class>org.foo.Six</class>
+ </decorators>
+ <alternatives>
+ <class>org.foo.Seven</class>
+ <class>org.foo.Eight</class>
+ <class>org.foo.Nine</class>
+ <stereotype>org.foo.Ten</stereotype>
+ <stereotype>org.foo.Eleven</stereotype>
+ <stereotype>org.foo.Twelve</stereotype>
+ </alternatives>
+</beans>
\ No newline at end of file
Propchange: openejb/branches/openejb-jcdi/container/openejb-jee/src/test/resources/beans-1.0-example.xml
------------------------------------------------------------------------------
svn:eol-style = native