Permalink
Browse files

Revert "AS7-6121: re-implements subsystem 'lookup' binding service wi…

…th a linkref, allowing Context#lookupLink() to return the link name"

This reverts commit 9ce9d00.
  • Loading branch information...
1 parent 2f610a6 commit d9e37a5a768a6ba4f4a3fdd692cab4d5d6064667 @bstansberry bstansberry committed Jan 4, 2013
Showing with 25 additions and 3 deletions.
  1. +25 −3 naming/src/main/java/org/jboss/as/naming/subsystem/NamingBindingAdd.java
@@ -36,7 +36,7 @@
import java.util.Hashtable;
import java.util.List;
-import javax.naming.LinkRef;
+import javax.naming.InitialContext;
import javax.naming.spi.ObjectFactory;
import org.jboss.as.controller.AbstractAddStepHandler;
@@ -252,9 +252,31 @@ void installLookup(final OperationContext context, final String name, final Mode
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
final BinderService binderService = new BinderService(name);
+ binderService.getManagedObjectInjector().inject(new ContextListAndJndiViewManagedReferenceFactory() {
+ @Override
+ public ManagedReference getReference() {
+ try {
+ final Object value = new InitialContext().lookup(lookup);
+ return new ValueManagedReference(new ImmediateValue<Object>(value));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String getInstanceClassName() {
+ final Object value = getReference().getInstance();
+ return value != null ? value.getClass().getName() : ContextListManagedReferenceFactory.DEFAULT_INSTANCE_CLASS_NAME;
+ }
+
+ @Override
+ public String getJndiViewInstanceValue() {
+ return String.valueOf(getReference().getInstance());
+ }
+ });
+
ServiceBuilder<ManagedReferenceFactory> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService)
- .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
- .addInjection(binderService.getManagedObjectInjector(), new ValueManagedReferenceFactory(new ImmediateValue<LinkRef>(new LinkRef(lookup))));
+ .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
if (verificationHandler != null) {
builder.addListener(verificationHandler);

0 comments on commit d9e37a5

Please sign in to comment.