@@ -0,0 +1,2748 @@
+/**%0A * Copyright (c) 2008 Intalio inc.%0A *%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *%0A * Contributors:%0A * Intalio inc. - initial API and implementation%0A */%0Apackage org.intalio.tempo.registry;%0A%0Aimport java.lang.reflect.Method;%0Aimport java.util.Properties;%0A%0Aimport javax.naming.Context;%0Aimport javax.naming.InitialContext;%0A%0A/**%0A * Registry implementation for JBoss that relies on org.jboss.naming.NonSerializableFactory%0A */%0Apublic class JBossRegistry implements Registry %7B%0A%0A    /**%0A     * Required no-arg public constructor%0A     */%0A    public JBossRegistry() %7B%0A        // nothing%0A    %7D%0A%0A    public %3CT%3E void bind(String name, T object) %7B%0A        try %7B%0A            InitialContext context = new InitialContext();%0A%0A            // Now we do the equivalent of:%0A            //   NonSerializableFactory.rebind(context, name, object);%0A            // using reflection%0A            Class clazz = null;%0A            try %7B%0A                clazz = Class.forName(%22org.jboss.naming.NonSerializableFactory%22);%0A            %7D catch (ClassNotFoundException ex) %7B%0A                clazz = Class.forName(%22org.jboss.naming.NonSerializableFactory%22, true, Thread.currentThread().getContextClassLoader());%0A            %7D%0A            Method method = clazz.getMethod(%22rebind%22, Context.class, String.class, Object.class);%0A            method.invoke(null, new Object%5B%5D %7B context, name, object %7D);%0A        %7D catch (Exception e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT%3E T lookup(String name) %7B%0A        return (T) lookup(name, Thread.currentThread().getContextClassLoader());%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT%3E T lookup(String name, ClassLoader loader) %7B%0A        T proxiedObject = null;%0A        try %7B%0A            InitialContext context = new InitialContext();%0A            proxiedObject = (T) context.lookup(name);%0A            if (proxiedObject == null) return null;%0A            RemoteProxy%3CT%3E proxy = new RemoteProxy%3CT%3E(proxiedObject, loader, proxiedObject.getClass().getClassLoader());%0A            return proxy.newProxyInstance();%0A        %7D catch (Exception e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT%3E T lookupNonProxied(String name) %7B%0A        try %7B%0A            InitialContext context = new InitialContext();%0A            return (T) context.lookup(name);%0A        %7D catch (Exception e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A    %0A    public void init(Properties props) %7B%0A        // nothing%0A    %7D%0A%0A%7D%0A

Add a specific JBoss Registry