Skip to content

Commit

Permalink
WS
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@318 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Nov 18, 2008
1 parent ae8c499 commit d537e59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Expand Up @@ -26,8 +26,7 @@ public ProxyMethodHandler(Bean<?> bean, int beanIndex, ManagerImpl manager)
ProxyMethodHandler.manager = manager;
}

public Object invoke(Object self, Method method, Method proceed,
Object[] args) throws Throwable
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
{
if (bean == null)
{
Expand All @@ -38,7 +37,5 @@ public Object invoke(Object self, Method method, Method proceed,
Method proxiedMethod = Reflections.lookupMethod(method, proxiedInstance);
return proxiedMethod.invoke(proxiedInstance, args);
}




}
Expand Up @@ -45,7 +45,8 @@ protected Map<Bean<?>, Object> delegate()
private ManagerImpl manager;
private Pool pool;

public ProxyPool(ManagerImpl manager) {
public ProxyPool(ManagerImpl manager)
{
this.manager = manager;
this.pool = new Pool();
}
Expand All @@ -55,14 +56,19 @@ private class TypeInfo {
Class<?> superclass;
}

private TypeInfo getTypeInfo(Set<Class<?>> types) {
private TypeInfo getTypeInfo(Set<Class<?>> types)
{
TypeInfo typeInfo = new TypeInfo();
List<Class<?>> interfaces = new ArrayList<Class<?>>();
Class<?> superclass = null;
for (Class<?> type : types) {
if (type.isInterface()) {
for (Class<?> type : types)
{
if (type.isInterface())
{
interfaces.add(type);
} else if (superclass == null || (type != Object.class && superclass.isAssignableFrom(type))) {
}
else if (superclass == null || (type != Object.class && superclass.isAssignableFrom(type)))
{
superclass = type;
}
}
Expand All @@ -72,14 +78,15 @@ private TypeInfo getTypeInfo(Set<Class<?>> types) {
return typeInfo;
}

private <T> T createClientProxy(Bean<T> bean, int beanIndex) throws InstantiationException, IllegalAccessException {
private <T> T createClientProxy(Bean<T> bean, int beanIndex) throws InstantiationException, IllegalAccessException
{
ProxyFactory proxyFactory = new ProxyFactory();
TypeInfo typeInfo = getTypeInfo(bean.getTypes());
proxyFactory.setInterfaces(typeInfo.interfaces);
proxyFactory.setSuperclass(typeInfo.superclass);
T clientProxy = (T) proxyFactory.createClass().newInstance();
ProxyMethodHandler proxyMethodHandler = new ProxyMethodHandler(bean, beanIndex, manager);
((ProxyObject)clientProxy).setHandler(proxyMethodHandler);
((ProxyObject) clientProxy).setHandler(proxyMethodHandler);
return clientProxy;
}

Expand All @@ -92,7 +99,8 @@ public Object getClientProxy(Bean<?> bean)
{
int beanIndex = manager.getBeans().indexOf(bean);
// Implicit add required since it is looked up on activation with then index
if (beanIndex < 0) {
if (beanIndex < 0)
{
manager.addBean(bean);
beanIndex = manager.getBeans().size() - 1;
}
Expand All @@ -108,5 +116,4 @@ public Object getClientProxy(Bean<?> bean)
return clientProxy;
}


}

0 comments on commit d537e59

Please sign in to comment.