Created
January 22, 2010 00:38
-
-
Save dblevins/283370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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.superbiz; | |
import junit.framework.TestCase; | |
import org.apache.openejb.config.ConfigurationFactory; | |
import org.apache.openejb.jee.EjbJar; | |
import org.apache.openejb.jee.StatelessBean; | |
import org.apache.openejb.assembler.classic.Assembler; | |
import org.apache.openejb.assembler.classic.TransactionServiceInfo; | |
import org.apache.openejb.assembler.classic.SecurityServiceInfo; | |
import org.apache.openejb.assembler.classic.EjbJarInfo; | |
import javax.ejb.Local; | |
import javax.ejb.Remote; | |
import javax.ejb.TransactionAttribute; | |
import static javax.ejb.TransactionAttributeType.MANDATORY; | |
import static javax.ejb.TransactionAttributeType.NEVER; | |
import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED; | |
import static javax.ejb.TransactionAttributeType.REQUIRES_NEW; | |
public class HandRolledAppTest extends TestCase { | |
public void test() throws Exception { | |
Assembler assembler = new Assembler(); | |
ConfigurationFactory config = new ConfigurationFactory(); | |
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); | |
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class)); | |
EjbJar ejbJar = new EjbJar(); | |
ejbJar.addEnterpriseBean(new StatelessBean(Color.class)); | |
ejbJar.addEnterpriseBean(new StatelessBean(Red.class)); | |
ejbJar.addEnterpriseBean(new StatelessBean(Crimson.class)); | |
ejbJar.addEnterpriseBean(new StatelessBean(Scarlet.class)); | |
EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar); | |
assembler.createApplication(ejbJarInfo); | |
//... | |
} | |
@Local | |
public static interface ColorLocal { | |
} | |
@Remote | |
public static interface ColorRemote { | |
} | |
@TransactionAttribute(MANDATORY) | |
public static class Color implements ColorLocal, ColorRemote { | |
@TransactionAttribute(NEVER) | |
public void color() { | |
} | |
@TransactionAttribute(REQUIRES_NEW) | |
public void color(Object o) { | |
} | |
public void color(String s) { | |
} | |
public void color(Boolean b) { | |
} | |
public void color(Integer i) { | |
} | |
} | |
public static class Red extends Color { | |
public void color(Object o) { | |
super.color(o); | |
} | |
@TransactionAttribute(REQUIRES_NEW) | |
public void red() { | |
} | |
public void red(Object o) { | |
} | |
public void red(String s) { | |
} | |
} | |
@TransactionAttribute(NOT_SUPPORTED) | |
public static class Crimson extends Red { | |
public void color() { | |
} | |
public void color(String s) { | |
} | |
@TransactionAttribute(REQUIRES_NEW) | |
public void crimson() { | |
} | |
public void crimson(String s) { | |
} | |
} | |
@TransactionAttribute(NOT_SUPPORTED) | |
public static class Scarlet extends Red { | |
@TransactionAttribute(REQUIRES_NEW) | |
public void scarlet() { | |
} | |
public void scarlet(String s) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment