Search in sources :

Example 1 with NamedMethod$JAXB.readNamedMethod

use of org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod in project tomee by apache.

the class ConcurrentMethod$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ConcurrentMethod concurrentMethod, RuntimeContext context) throws Exception {
    if (concurrentMethod == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ConcurrentMethod.class != concurrentMethod.getClass()) {
        context.unexpectedSubclass(writer, concurrentMethod, ConcurrentMethod.class);
        return;
    }
    context.beforeMarshal(concurrentMethod, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = concurrentMethod.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(concurrentMethod, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: method
    final NamedMethod method = concurrentMethod.method;
    if (method != null) {
        writer.writeStartElement(prefix, "method", "http://java.sun.com/xml/ns/javaee");
        writeNamedMethod(writer, method, context);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(concurrentMethod, "method");
    }
    // ELEMENT: lock
    final ConcurrentLockType lock = concurrentMethod.lock;
    if (lock != null) {
        writer.writeStartElement(prefix, "lock", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(toStringConcurrentLockType(concurrentMethod, null, context, lock));
        writer.writeEndElement();
    }
    // ELEMENT: accessTimeout
    final Timeout accessTimeout = concurrentMethod.accessTimeout;
    if (accessTimeout != null) {
        writer.writeStartElement(prefix, "access-timeout", "http://java.sun.com/xml/ns/javaee");
        writeTimeout(writer, accessTimeout, context);
        writer.writeEndElement();
    }
    context.afterMarshal(concurrentMethod, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Timeout$JAXB.readTimeout(org.apache.openejb.jee.Timeout$JAXB.readTimeout) Timeout$JAXB.writeTimeout(org.apache.openejb.jee.Timeout$JAXB.writeTimeout) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) NamedMethod$JAXB.readNamedMethod(org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod) NamedMethod$JAXB.writeNamedMethod(org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod) ConcurrentLockType$JAXB.parseConcurrentLockType(org.apache.openejb.jee.ConcurrentLockType$JAXB.parseConcurrentLockType) ConcurrentLockType$JAXB.toStringConcurrentLockType(org.apache.openejb.jee.ConcurrentLockType$JAXB.toStringConcurrentLockType)

Example 2 with NamedMethod$JAXB.readNamedMethod

use of org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod in project tomee by apache.

the class ConcurrentMethod$JAXB method _read.

public static final ConcurrentMethod _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ConcurrentMethod concurrentMethod = new ConcurrentMethod();
    context.beforeUnmarshal(concurrentMethod, LifecycleCallback.NONE);
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("concurrent-methodType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ConcurrentMethod.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, concurrentMethod);
            concurrentMethod.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: method
            final NamedMethod method = readNamedMethod(elementReader, context);
            concurrentMethod.method = method;
        } else if (("lock" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lock
            final ConcurrentLockType lock = parseConcurrentLockType(elementReader, context, elementReader.getElementAsString());
            if (lock != null) {
                concurrentMethod.lock = lock;
            }
        } else if (("access-timeout" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: accessTimeout
            final Timeout accessTimeout = readTimeout(elementReader, context);
            concurrentMethod.accessTimeout = accessTimeout;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "method"), new QName("http://java.sun.com/xml/ns/javaee", "lock"), new QName("http://java.sun.com/xml/ns/javaee", "access-timeout"));
        }
    }
    context.afterUnmarshal(concurrentMethod, LifecycleCallback.NONE);
    return concurrentMethod;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) Timeout$JAXB.readTimeout(org.apache.openejb.jee.Timeout$JAXB.readTimeout) Timeout$JAXB.writeTimeout(org.apache.openejb.jee.Timeout$JAXB.writeTimeout) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) NamedMethod$JAXB.readNamedMethod(org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod) NamedMethod$JAXB.writeNamedMethod(org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod) ConcurrentLockType$JAXB.parseConcurrentLockType(org.apache.openejb.jee.ConcurrentLockType$JAXB.parseConcurrentLockType) ConcurrentLockType$JAXB.toStringConcurrentLockType(org.apache.openejb.jee.ConcurrentLockType$JAXB.toStringConcurrentLockType) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 3 with NamedMethod$JAXB.readNamedMethod

use of org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod in project tomee by apache.

the class FullyInterceptedTest method module.

@Module
public EjbJar module() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(FullyInterceptedBean.class));
    final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
    final InterceptorBinding b = assembly.addInterceptorBinding(new InterceptorBinding(bean));
    b.setExcludeDefaultInterceptors(true);
    b.setMethod(new NamedMethod("methodWithDefaultInterceptorsExcluded"));
    return ejbJar;
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) NamedMethod(org.apache.openejb.jee.NamedMethod) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar) Module(org.apache.openejb.testing.Module)

Example 4 with NamedMethod$JAXB.readNamedMethod

use of org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod in project tomee by apache.

the class ScheduleTest method testSchedule.

public void testSchedule() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final Assembler assembler = new Assembler();
    final ConfigurationFactory config = new ConfigurationFactory();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    //Configure schedule by deployment plan
    final StatelessBean subBeanA = new StatelessBean(SubBeanA.class);
    final Timer subBeanATimer = new Timer();
    subBeanATimer.setTimeoutMethod(new NamedMethod("subBeanA", "javax.ejb.Timer"));
    final TimerSchedule timerScheduleA = new TimerSchedule();
    timerScheduleA.setSecond("2");
    timerScheduleA.setMinute("*");
    timerScheduleA.setHour("*");
    subBeanATimer.setSchedule(timerScheduleA);
    subBeanATimer.setInfo("SubBeanAInfo");
    subBeanA.getTimer().add(subBeanATimer);
    ejbJar.addEnterpriseBean(subBeanA);
    //Configure schedule by annotation
    final StatelessBean subBeanB = new StatelessBean(SubBeanB.class);
    ejbJar.addEnterpriseBean(subBeanB);
    //Override aroundTimeout annotation by deployment plan
    final StatelessBean subBeanC = new StatelessBean(SubBeanC.class);
    final Timer subBeanCTimer = new Timer();
    subBeanCTimer.setTimeoutMethod(new NamedMethod("subBeanC", "javax.ejb.Timer"));
    final TimerSchedule timerScheduleC = new TimerSchedule();
    timerScheduleC.setSecond("2");
    timerScheduleC.setMinute("*");
    timerScheduleC.setHour("*");
    subBeanCTimer.setSchedule(timerScheduleC);
    subBeanCTimer.setInfo("SubBeanCInfo");
    subBeanC.getTimer().add(subBeanCTimer);
    ejbJar.addEnterpriseBean(subBeanC);
    final StatefulBean subBeanM = new StatefulBean(SubBeanM.class);
    ejbJar.addEnterpriseBean(subBeanM);
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assembler.createApplication(ejbJarInfo);
    countDownLatch.await(1L, TimeUnit.MINUTES);
    //A better way for validation ?
    int beforeAroundInvocationCount = 0;
    int afterAroundInvocationCount = 0;
    int timeoutInvocationCount = 0;
    final int size;
    synchronized (result) {
        size = result.size();
        for (final Call call : result) {
            switch(call) {
                case BEAN_BEFORE_AROUNDTIMEOUT:
                    beforeAroundInvocationCount++;
                    break;
                case BEAN_AFTER_AROUNDTIMEOUT:
                    afterAroundInvocationCount++;
                    break;
                case TIMEOUT:
                    timeoutInvocationCount++;
                    break;
            }
        }
    }
    assertEquals(3, beforeAroundInvocationCount);
    assertEquals(3, afterAroundInvocationCount);
    assertEquals(3, timeoutInvocationCount);
    assertEquals(9, size);
}
Also used : StatefulBean(org.apache.openejb.jee.StatefulBean) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) NamedMethod(org.apache.openejb.jee.NamedMethod) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TimerSchedule(org.apache.openejb.jee.TimerSchedule) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) Timer(org.apache.openejb.jee.Timer) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 5 with NamedMethod$JAXB.readNamedMethod

use of org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod in project tomee by apache.

the class StatefulConcurrencyTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    assembler.createContainer(statefulContainerInfo);
    final EjbJar ejbJar = new EjbJar();
    final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
    final Timeout timeout1 = new Timeout();
    timeout1.setTimeout(1000);
    timeout1.setUnit(TimeUnit.MILLISECONDS);
    final ConcurrentMethod method1 = new ConcurrentMethod();
    method1.setMethod(new NamedMethod("*"));
    method1.setAccessTimeout(timeout1);
    bean1.getConcurrentMethod().add(method1);
    final StatefulBean bean2 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
    final Timeout timeout2 = new Timeout();
    timeout2.setTimeout(-1);
    timeout2.setUnit(TimeUnit.MILLISECONDS);
    final ConcurrentMethod method2 = new ConcurrentMethod();
    method2.setMethod(new NamedMethod("*"));
    method2.setAccessTimeout(timeout2);
    bean2.getConcurrentMethod().add(method2);
    ejbJar.addEnterpriseBean(bean1);
    ejbJar.addEnterpriseBean(bean2);
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatefulBean(org.apache.openejb.jee.StatefulBean) Timeout(org.apache.openejb.jee.Timeout) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) ConcurrentMethod(org.apache.openejb.jee.ConcurrentMethod) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) NamedMethod(org.apache.openejb.jee.NamedMethod) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

NamedMethod$JAXB.readNamedMethod (org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod)14 NamedMethod$JAXB.writeNamedMethod (org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod)14 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)14 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)11 NamedMethod (org.apache.openejb.jee.NamedMethod)11 EjbJar (org.apache.openejb.jee.EjbJar)10 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)8 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)8 StatefulBean (org.apache.openejb.jee.StatefulBean)6 ArrayList (java.util.ArrayList)5 QName (javax.xml.namespace.QName)5 Interceptor (org.apache.openejb.jee.Interceptor)5 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)5 Attribute (org.metatype.sxc.util.Attribute)5 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)5 AroundInvoke$JAXB.readAroundInvoke (org.apache.openejb.jee.AroundInvoke$JAXB.readAroundInvoke)4 AroundInvoke$JAXB.writeAroundInvoke (org.apache.openejb.jee.AroundInvoke$JAXB.writeAroundInvoke)4 AroundTimeout$JAXB.readAroundTimeout (org.apache.openejb.jee.AroundTimeout$JAXB.readAroundTimeout)4 AroundTimeout$JAXB.writeAroundTimeout (org.apache.openejb.jee.AroundTimeout$JAXB.writeAroundTimeout)4 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)4