[jboss-cvs] JBossAS SVN: r69577 - in projects/ejb3/trunk/core/src/main/java/org/jboss: ejb3/cache/tree and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 4 08:17:31 EST 2008
Author: wolfc
Date: 2008-02-04 08:17:31 -0500 (Mon, 04 Feb 2008)
New Revision: 69577
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/JmxDeploymentUnit.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/MCKernelAbstraction.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/JaasSecurityManagerService.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDB.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/security/RoleBasedAuthorizationInterceptorv2.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/injection/WebServiceRefHandler.java
Log:
Merged AS trunk up to 69575
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -1248,7 +1248,7 @@
public MethodInfo getMethodInfo(Method method)
{
long hash = MethodHashing.calculateHash(method);
- MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
+ MethodInfo info = super.getMethodInfo(hash);
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -347,7 +347,9 @@
{
ObjectName on = container.getObjectName();
String name = on.getCanonicalName();
- kernelAbstraction.install(name, container.getDependencyPolicy(), container);
+ DependencyPolicy dependsPolicy = container.getDependencyPolicy();
+ dependsPolicy.addDependency("jboss.ejb:service=EJBTimerService");
+ kernelAbstraction.install(name, dependsPolicy, container);
mbeanServer.registerMBean(container.getMBean(), on);
log.debug("Bound ejb3 container " + name);
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/JmxDeploymentUnit.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/JmxDeploymentUnit.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/JmxDeploymentUnit.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -244,7 +244,7 @@
{
try
{
- return vfsRoot.findChild(path);
+ return vfsRoot.getChild(path);
}
catch (IOException e)
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/MCKernelAbstraction.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/MCKernelAbstraction.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/MCKernelAbstraction.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -36,6 +36,7 @@
import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.beans.metadata.spi.DemandMetaData;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
@@ -124,21 +125,22 @@
log.info("installing bean: " + name + " with dependencies:");
for (Object obj : policy.getDependencies())
{
- String msg;
+ Object msgObject = obj;
if (obj instanceof AbstractDemandMetaData)
{
- msg = ((AbstractDemandMetaData)obj).getDemand().toString();
+ msgObject = ((AbstractDemandMetaData)obj).getDemand();
}
- else
- {
- msg = obj.toString();
- }
- log.info("\t" + msg);
+ log.info("\t" + msgObject);
}
+ log.info(" and demands:");
+ for(DemandMetaData dmd : policy.getDemands())
+ {
+ log.info("\t" + dmd.getDemand());
+ }
log.info(" and supplies:");
for(SupplyMetaData smd : policy.getSupplies())
{
- log.info("\t" + smd.getSupply().toString());
+ log.info("\t" + smd.getSupply());
}
try
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -68,7 +68,7 @@
*
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author Brian Stansberry
- *
+ *
* @version $Revision$
*/
public class StatefulTreeCache implements ClusteredStatefulCache
@@ -77,15 +77,20 @@
private static final int DEFAULT_BUCKET_COUNT = 100;
private static final String[] DEFAULT_HASH_BUCKETS = new String[DEFAULT_BUCKET_COUNT];
-
+
+ private static Option LOCAL_ONLY_OPTION = new Option();
+ private static Option GRAVITATE_OPTION = new Option();
static
{
+ LOCAL_ONLY_OPTION.setCacheModeLocal(true);
+ GRAVITATE_OPTION.setForceDataGravitation(true);
+
for (int i = 0; i < DEFAULT_HASH_BUCKETS.length; i++)
{
DEFAULT_HASH_BUCKETS[i] = String.valueOf(i);
}
}
-
+
private ThreadLocal<Boolean> localActivity = new ThreadLocal<Boolean>();
private Logger log = Logger.getLogger(StatefulTreeCache.class);
private Pool pool;
@@ -94,14 +99,14 @@
private Fqn cacheNode;
private Region region;
private ClusteredStatefulCacheListener listener;
-
+
public static long MarkInUseWaitTime = 15000;
-
+
protected String[] hashBuckets = DEFAULT_HASH_BUCKETS;
protected int createCount = 0;
protected int passivatedCount = 0;
protected int removeCount = 0;
- protected long removalTimeout = 0;
+ protected long removalTimeout = 0;
protected RemovalTimeoutTask removalTask = null;
protected boolean running = true;
protected Map<Object, Long> beans = new ConcurrentHashMap<Object, Long>();
@@ -165,7 +170,7 @@
{
return get(key, true);
}
-
+
public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException
{
StatefulBeanContext entry = null;
@@ -188,35 +193,35 @@
{
localActivity.set(active);
}
-
+
if (entry == null)
{
throw new NoSuchEJBException("Could not find stateful bean: " + key);
}
else if (markInUse && entry.isRemoved())
{
- throw new NoSuchEJBException("Could not find stateful bean: " + key +
+ throw new NoSuchEJBException("Could not find stateful bean: " + key +
" (bean was marked as removed)");
}
-
+
entry.postReplicate();
-
+
if (markInUse)
{
entry.setInUse(true);
-
+
// Mark the Fqn telling the eviction thread not to passivate it yet.
// Note the Fqn we use is relative to the region!
region.markNodeCurrentlyInUse(new Fqn(key.toString()), MarkInUseWaitTime);
entry.lastUsed = System.currentTimeMillis();
beans.put(key, new Long(entry.lastUsed));
}
-
+
if(log.isTraceEnabled())
{
log.trace("get: retrieved bean with cache id " +id.toString());
}
-
+
return entry;
}
@@ -224,7 +229,7 @@
{
return get(key, false);
}
-
+
public void remove(Object key)
{
Fqn id = getFqn(key, false);
@@ -236,13 +241,13 @@
}
InvocationContext ictx = cache.getInvocationContext();
ictx.setOptionOverrides(getGravitateOption());
- StatefulBeanContext ctx = (StatefulBeanContext) cache.get(id, "bean");
-
+ StatefulBeanContext ctx = (StatefulBeanContext) cache.get(id, "bean");
+
if (ctx != null)
{
if (!ctx.isRemoved())
pool.remove(ctx);
-
+
if (ctx.getCanRemoveFromCache())
{
// Do a cluster-wide removal of the ctx
@@ -254,7 +259,7 @@
// But, we must replicate it so other nodes know the parent is removed!
putInCache(ctx);
}
-
+
++removeCount;
beans.remove(key);
}
@@ -288,7 +293,7 @@
{
throw new IllegalArgumentException("Received unexpected replicate call for nested context " + ctx.getId());
}
-
+
try
{
putInCache(ctx);
@@ -303,13 +308,13 @@
public void initialize(Container container) throws Exception
{
this.ejbContainer = (EJBContainer) container;
-
+
log = Logger.getLogger(getClass().getName() + "." + this.ejbContainer.getEjbName());
-
+
this.pool = this.ejbContainer.getPool();
ClassLoader cl = this.ejbContainer.getClassloader();
this.classloader = new WeakReference<ClassLoader>(cl);
-
+
Advisor advisor = this.ejbContainer;
CacheConfig config = (CacheConfig) advisor.resolveAnnotation(CacheConfig.class);
MBeanServer server = MBeanServerLocator.locateJBoss();
@@ -327,21 +332,21 @@
EvictionPolicyConfig epc = getEvictionPolicyConfig((int) config.idleTimeoutSeconds(),
config.maxSize());
region.setEvictionPolicy(epc);
-
+
// JBCACHE-1136. There's no reason to have state in an inactive region
cleanBeanRegion();
-
+
// Transfer over the state for the region
region.registerContextClassLoader(cl);
region.activate();
-
+
log.debug("initialize(): created region: " +region + " for ejb: " + this.ejbContainer.getEjbName());
-
+
removalTimeout = config.removalTimeoutSeconds();
if (removalTimeout > 0)
removalTask = new RemovalTimeoutTask("SFSB Removal Thread - " + this.ejbContainer.getObjectName().getCanonicalName());
}
-
+
protected EvictionPolicyConfig getEvictionPolicyConfig(int timeToLiveSeconds, int maxNodes)
{
LRUConfiguration epc = new LRUConfiguration();
@@ -355,16 +360,16 @@
public void start()
{
// register to listen for cache events
-
- // TODO this approach may not be scalable when there are many beans
- // since then we will need to go thru N listeners to figure out which
+
+ // TODO this approach may not be scalable when there are many beans
+ // since then we will need to go thru N listeners to figure out which
// one this event belongs to. Consider having a singleton listener
listener = new ClusteredStatefulCacheListener();
cache.addCacheListener(listener);
-
+
if (removalTask != null)
removalTask.start();
-
+
running = true;
}
@@ -377,28 +382,28 @@
// Remove the listener
if (listener != null)
cache.removeCacheListener(listener);
-
+
// Remove locally. We do this to clean up the persistent store,
// which is not affected by the inactivateRegion call below.
- cleanBeanRegion();
-
+ cleanBeanRegion();
+
try {
// Remove locally. We do this to clean up the persistent store,
// which is not affected by the region.deactivate call below.
InvocationContext ctx = cache.getInvocationContext();
ctx.setOptionOverrides(getLocalOnlyOption());
cache.removeNode(cacheNode);
- }
- catch (CacheException e)
+ }
+ catch (CacheException e)
{
log.error("stop(): can't remove bean from the underlying distributed cache");
}
-
+
if (region != null)
{
region.deactivate();
- region.unregisterContextClassLoader();
-
+ region.unregisterContextClassLoader();
+
// FIXME this method needs to be in Cache
((CacheSPI) cache).getRegionManager().removeRegion(region.getFqn());
// Clear any queues
@@ -406,15 +411,15 @@
region = null;
}
}
-
+
classloader = null;
-
+
if (removalTask != null)
removalTask.interrupt();
-
+
log.debug("stop(): StatefulTreeCache stopped successfully for " +cacheNode);
}
-
+
public int getCacheSize()
{
int count = 0;
@@ -444,37 +449,37 @@
{
return beans.size();
}
-
+
public int getCreateCount()
{
return createCount;
}
-
+
public int getPassivatedCount()
{
return passivatedCount;
}
-
+
public int getRemoveCount()
{
return removeCount;
}
-
+
public int getAvailableCount()
{
return -1;
}
-
+
public int getMaxSize()
{
return -1;
}
-
+
public int getCurrentSize()
{
return getCacheSize();
}
-
+
private void putInCache(StatefulBeanContext ctx)
{
Boolean active = localActivity.get();
@@ -483,14 +488,14 @@
localActivity.set(Boolean.TRUE);
ctx.preReplicate();
cache.put(getFqn(ctx.getId(), false), "bean", ctx);
- ctx.markedForReplication = false;
+ ctx.markedForReplication = false;
}
finally
{
localActivity.set(active);
- }
+ }
}
-
+
private Fqn getFqn(Object id, boolean regionRelative)
{
String beanId = id.toString();
@@ -503,32 +508,32 @@
{
index = (beanId.hashCode()& 0x7FFFFFFF) % hashBuckets.length;
}
-
+
if (regionRelative)
return new Fqn( new Object[] {hashBuckets[index], beanId} );
else
return new Fqn(cacheNode, hashBuckets[index], beanId);
}
-
+
private void cleanBeanRegion()
{
try {
// Remove locally.
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache.removeNode(cacheNode);
- }
- catch (CacheException e)
+ }
+ catch (CacheException e)
{
log.error("Stop(): can't remove bean from the underlying distributed cache");
- }
+ }
}
-
- /**
+
+ /**
* Creates a RuntimeException, but doesn't pass CacheException as the cause
* as it is a type that likely doesn't exist on a client.
* Instead creates a RuntimeException with the original exception's
* stack trace.
- */
+ */
private RuntimeException convertToRuntimeException(CacheException e)
{
RuntimeException re = new RuntimeException(e.getClass().getName() + " " + e.getMessage());
@@ -554,17 +559,17 @@
if(fqn.size() != FQN_SIZE) return;
if(!fqn.isChildOrEquals(cacheNode)) return;
- // Don't activate a bean just so we can replace the object
+ // Don't activate a bean just so we can replace the object
// with a replicated one
- if (Boolean.TRUE != localActivity.get())
+ if (Boolean.TRUE != localActivity.get())
{
// But we do want to record that the bean's now in memory
--passivatedCount;
- return;
+ return;
}
-
+
StatefulBeanContext bean = (StatefulBeanContext) nodeData.get("bean");
-
+
if(bean == null)
{
throw new IllegalStateException("nodeLoaded(): null bean instance.");
@@ -576,27 +581,27 @@
{
log.trace("nodeLoaded(): send postActivate event to bean at fqn: " +fqn);
}
-
+
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try
- {
+ {
ClassLoader cl = classloader.get();
if (cl != null)
{
Thread.currentThread().setContextClassLoader(cl);
}
-
+
bean.activateAfterReplication();
}
finally
{
Thread.currentThread().setContextClassLoader(oldCl);
}
-
+
}
@NodePassivated
- public void nodePassivated(NodePassivatedEvent event)
+ public void nodePassivated(NodePassivatedEvent event)
{
// Ignore everything but "pre" events for nodes in our region
if(!event.isPre()) return;
@@ -606,8 +611,8 @@
StatefulBeanContext bean = null;
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
- Boolean active = localActivity.get();
- try
+ Boolean active = localActivity.get();
+ try
{
localActivity.set(Boolean.TRUE);
bean = (StatefulBeanContext) event.getData().get("bean");
@@ -618,19 +623,19 @@
{
Thread.currentThread().setContextClassLoader(cl);
}
-
+
if (!bean.getCanPassivate())
{
// Abort the eviction
- throw new ContextInUseException("Cannot passivate bean " + fqn +
+ throw new ContextInUseException("Cannot passivate bean " + fqn +
" -- it or one if its children is currently in use");
}
-
+
if(log.isTraceEnabled())
{
log.trace("nodePassivated(): send prePassivate event to bean at fqn: " +fqn);
}
-
+
bean.passivateAfterReplication();
++passivatedCount;
}
@@ -674,21 +679,17 @@
}
}
}
-
+
private static Option getLocalOnlyOption()
{
- Option opt = new Option();
- opt.setCacheModeLocal(true);
- return opt;
+ return LOCAL_ONLY_OPTION.clone();
}
-
+
private static Option getGravitateOption()
{
- Option opt = new Option();
- opt.setForceDataGravitation(true);
- return opt;
+ return GRAVITATE_OPTION.clone();
}
-
+
private class RemovalTimeoutTask extends Thread
{
public RemovalTimeoutTask(String name)
@@ -712,7 +713,7 @@
try
{
long now = System.currentTimeMillis();
-
+
Iterator<Map.Entry<Object, Long>> it = beans.entrySet().iterator();
while (it.hasNext())
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -250,7 +250,7 @@
{
try
{
- return vfsRoot.findChild(path);
+ return vfsRoot.getChild(path);
}
catch (IOException e)
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/JaasSecurityManagerService.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/JaasSecurityManagerService.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/embedded/JaasSecurityManagerService.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -114,7 +114,7 @@
*/
String securityDomainName = name.get(1);
final SecurityDomainContext ctx = new SecurityDomainContext(getSecurityManager(securityDomainName), null);
- ctx.setAuthorizationManager(new JBossAuthorizationManager(securityDomainName, new SecurityAssociationHandler()));
+ ctx.setAuthorizationManager(new JBossAuthorizationManager(securityDomainName));
return new BrainlessContext()
{
public Object lookup(Name name) throws NamingException
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -98,7 +98,7 @@
{
Thread.currentThread().setContextClassLoader(classloader);
MethodInvocation si = (MethodInvocation) invocation;
- MethodInfo info = (MethodInfo) methodInterceptors.get(si.getMethodHash());
+ MethodInfo info = super.getMethodInfo(si.getMethodHash());
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call");
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDB.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDB.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDB.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -73,7 +73,7 @@
messagingType = annotation.messageListenerInterface();
if (messagingType.getName().equals(Object.class.getName()))
{
- Set<Class<?>> businessInterfaces = ProxyFactoryHelper.getBusinessInterfaces(clazz,true);
+ Set<Class<?>> businessInterfaces = ProxyFactoryHelper.getBusinessInterfaces(clazz,false);
if (businessInterfaces.size() > 1 || businessInterfaces.size() == 0)
throw new RuntimeException("Unable to choose messagingType interface for MDB " + getEjbName() + " from " + businessInterfaces);
messagingType = businessInterfaces.iterator().next();
@@ -86,7 +86,7 @@
public MethodInfo getMethodInfo(Method method)
{
long hash = MethodHashing.calculateHash(method);
- MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
+ MethodInfo info = super.getMethodInfo(hash);
return info;
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/security/RoleBasedAuthorizationInterceptorv2.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/security/RoleBasedAuthorizationInterceptorv2.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/security/RoleBasedAuthorizationInterceptorv2.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -122,6 +122,10 @@
public Object invoke(Invocation invocation) throws Throwable
{
+ //Set the JACC ContextID
+ String contextID = (String) invocation.getMetaData("JACC", "ctx");
+ SecurityActions.setContextID(contextID);
+
MethodInvocation mi = (MethodInvocation)invocation;
//Check for ejbTimeOut
SecurityHelper shelper = new SecurityHelper();
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-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -345,7 +345,7 @@
Thread.currentThread().setContextClassLoader(classloader);
long hash = MethodHashing.calculateHash(method);
- MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
+ MethodInfo info = super.getMethodInfo(hash);
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
@@ -386,7 +386,7 @@
EJBContainerInvocation newSi = null;
MethodInvocation si = (MethodInvocation) invocation;
- MethodInfo info = (MethodInfo) methodInterceptors.get(si.getMethodHash());
+ MethodInfo info = super.getMethodInfo(si.getMethodHash());
Method method = info.getUnadvisedMethod();
try
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -357,7 +357,7 @@
try
{
long hash = MethodHashing.calculateHash(method);
- MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
+ MethodInfo info = super.getMethodInfo(hash);
if (info == null)
{
throw new RuntimeException(
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -196,7 +196,7 @@
try
{
long hash = MethodHashing.calculateHash(method);
- MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
+ MethodInfo info = super.getMethodInfo(hash);
if (info == null)
{
throw new RuntimeException(
@@ -227,7 +227,7 @@
try
{
long hash = MethodHashing.calculateHash(method);
- MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
+ MethodInfo info = super.getMethodInfo(hash);
if (info == null)
{
throw new RuntimeException(
@@ -328,7 +328,7 @@
{
Thread.currentThread().setContextClassLoader(classloader);
StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;
- MethodInfo info = (MethodInfo) methodInterceptors.get(si.getMethodHash());
+ MethodInfo info = super.getMethodInfo(si.getMethodHash());
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call");
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -174,7 +174,7 @@
AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsFlags.IN_EJB_TIMEOUT);
try
{
- MethodInfo info = (MethodInfo) methodInterceptors.get(callbackHandler.getTimeoutCalllbackHash());
+ MethodInfo info = super.getMethodInfo(callbackHandler.getTimeoutCalllbackHash());
EJBContainerInvocation nextInvocation = new EJBContainerInvocation(info);
nextInvocation.setAdvisor(this);
nextInvocation.setArguments(args);
@@ -277,7 +277,7 @@
{
Thread.currentThread().setContextClassLoader(classloader);
MethodInvocation si = (MethodInvocation) invocation;
- MethodInfo info = (MethodInfo) methodInterceptors.get(si.getMethodHash());
+ MethodInfo info = super.getMethodInfo(si.getMethodHash());
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call");
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/WebServiceRefHandler.java 2008-02-04 13:16:31 UTC (rev 69576)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/WebServiceRefHandler.java 2008-02-04 13:17:31 UTC (rev 69577)
@@ -28,6 +28,7 @@
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+import java.util.Iterator;
import javax.naming.Context;
import javax.xml.ws.WebServiceRef;
@@ -35,9 +36,7 @@
import org.jboss.logging.Logger;
import org.jboss.metadata.javaee.jboss.JBossServiceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
+import org.jboss.metadata.javaee.spec.*;
/**
* Handle @WebServiceRef annotations
@@ -98,42 +97,124 @@
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
- WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
- if (wsref == null) return;
+ String serviceRefName = null;
+ // injector first
+ ServiceReferenceMetaData tmp = getServiceRefForInjectionTarget(method);
+ if(tmp!=null)
+ {
+ serviceRefName = tmp.getServiceRefName();
+ }
+ else
+ {
+ // annotation second
+ WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
+ if(wsref!=null)
+ {
+ serviceRefName = wsref.name();
+
+ if (serviceRefName.equals(""))
+ serviceRefName = InjectionUtil.getEncName(method).substring(4);
+ }
+ }
+
+ if(null==serviceRefName)
+ return;
+
if (!method.getName().startsWith("set"))
throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
-
- String name = wsref.name();
- if (name.equals(""))
- name = InjectionUtil.getEncName(method).substring(4);
- String encName = "env/" + name;
+ String encName = "env/" + serviceRefName;
Context encCtx = container.getEnc();
- if (!container.getEncInjectors().containsKey(name))
+ if (!container.getEncInjectors().containsKey(serviceRefName))
{
- ServiceReferenceMetaData sref = getServiceRef(name);
- container.getEncInjectors().put(name, new ServiceRefInjector(encName, method, sref));
+ ServiceReferenceMetaData sref = getServiceRef(serviceRefName);
+ container.getEncInjectors().put(serviceRefName, new ServiceRefInjector(encName, method, sref));
}
injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
}
+ private ServiceReferenceMetaData getServiceRefForInjectionTarget(Method method)
+ {
+ ServiceReferenceMetaData match = null;
+
+ Iterator<String> iterator = srefMap.keySet().iterator();
+ while(iterator.hasNext())
+ {
+ ServiceReferenceMetaData sref = srefMap.get(iterator.next());
+ if(sref.getInjectionTargets()!=null)
+ {
+ for(ResourceInjectionTargetMetaData injectionTuple : sref.getInjectionTargets())
+ {
+ if(method.getDeclaringClass().getName().equals(injectionTuple.getInjectionTargetClass())
+ && method.getName().equals(injectionTuple.getInjectionTargetName()))
+ {
+ match = sref;
+ break;
+ }
+ }
+ }
+ }
+ return match;
+ }
+
+ private ServiceReferenceMetaData getServiceRefForInjectionTarget(Field field)
+ {
+ ServiceReferenceMetaData match = null;
+
+ Iterator<String> iterator = srefMap.keySet().iterator();
+ while(iterator.hasNext())
+ {
+ ServiceReferenceMetaData sref = srefMap.get(iterator.next());
+ if(sref.getInjectionTargets()!=null)
+ {
+ for(ResourceInjectionTargetMetaData injectionTuple : sref.getInjectionTargets())
+ {
+ if(field.getDeclaringClass().getName().equals(injectionTuple.getInjectionTargetClass())
+ && field.getName().equals(injectionTuple.getInjectionTargetName()))
+ {
+ match = sref;
+ break;
+ }
+ }
+ }
+ }
+ return match;
+ }
+
public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
- WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
- if (wsref == null) return;
+ String serviceRefName = null;
- String name = wsref.name();
- if (name.equals(""))
- name = InjectionUtil.getEncName(field).substring(4);
+ // injector first
+ ServiceReferenceMetaData tmp = getServiceRefForInjectionTarget(field);
+ if(tmp!=null)
+ {
+ serviceRefName = tmp.getServiceRefName();
+ }
+ else
+ {
+ // annotation second
+ WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
+ if(wsref!=null)
+ {
+ serviceRefName = wsref.name();
- String encName = "env/" + name;
+ if (serviceRefName.equals(""))
+ serviceRefName = InjectionUtil.getEncName(field).substring(4);
+ }
+ }
+
+ if(null==serviceRefName)
+ return;
+
+ String encName = "env/" + serviceRefName;
Context encCtx = container.getEnc();
- if (!container.getEncInjectors().containsKey(name))
+ if (!container.getEncInjectors().containsKey(serviceRefName))
{
- ServiceReferenceMetaData sref = getServiceRef(name);
- container.getEncInjectors().put(name, new ServiceRefInjector(encName, field, sref));
+ ServiceReferenceMetaData sref = getServiceRef(serviceRefName);
+ container.getEncInjectors().put(serviceRefName, new ServiceRefInjector(encName, field, sref));
}
injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
More information about the jboss-cvs-commits
mailing list