Skip to content

Instantly share code, notes, and snippets.

View dblevins's full-sized avatar

David Blevins dblevins

View GitHub Profile
/**
* 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
*
/**
* 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
*
#!/bin/bash
REPO=$HOME/.m2/repository
CP=$REPO/asm/asm/2.2.3/asm-2.2.3.jar
CP=$CP:$REPO/asm/asm-attrs/2.2.3/asm-attrs-2.2.3.jar
CP=$CP:$REPO/asm/asm-util/2.2.3/asm-util-2.2.3.jar
java -cp $CP org.objectweb.asm.util.ASMifierClassVisitor $@
/**
* 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
*
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class InvocationContextPropagator {
private final static ThreadLocal context = new ThreadLocal();
@AroundInvoke
public Object intercept(InvocationContext newContext) throws Exception {
// Get the previous InvocationContext
InvocationContext oldContext = context.get();
@Stateless
@EJBs({
@EJB(name = "myFooEjb", beanInterface = FooRemote.class),
@EJB(name = "myBarEjb", beanInterface = BarRemote.class)
})
public class MyEjbRemoteRefBean implements MyBeanInterface {
@EJB
private BarRemote myBarEjb;
@Stateless
@EJB(name = "myFooEjb", beanInterface = FooRemote.class)
@EJB(name = "myBarEjb", beanInterface = BarRemote.class)
public class MyEjbRemoteRefBean implements MyBeanInterface {
@EJB
private BarRemote myBarEjb;
public void someBusinessMethod() throws Exception {
if (myBarEjb == null) throw new NullPointerException("myBarEjb not injected");
@Stateless
@EJB(name = "myFooEjb", beanInterface = FooRemote.class)
public class MyEjbRemoteRefBean implements MyBeanInterface {
public List<FooRemote> giveMeManyInstances(int number) throws Exception {
List<FooRemote> beans = new ArrayList<FooRemote>();
// Both can be looked up from JNDI as well
InitialContext context = new InitialContext();
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="false"
version="2.5">
<ejb-ref>
<ejb-ref-name>EntityBeansJobStore</ejb-ref-name>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="false"
version="2.5">
<ejb-ref>
<ejb-ref-name>EntityBeansJobStore</ejb-ref-name>