11/*
2- * Copyright (c) 2010, 2024 IBM Corporation and others.
2+ * Copyright (c) 2010, 2025 IBM Corporation and others.
33 * All rights reserved. This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License 2.0
55 * which accompanies this distribution, and is available at
2525import javax .naming .InvalidNameException ;
2626import javax .naming .NameClassPair ;
2727import javax .naming .NamingException ;
28+ import javax .transaction .TransactionManager ;
2829import javax .transaction .TransactionSynchronizationRegistry ;
2930import javax .transaction .UserTransaction ;
3031
3132import org .osgi .framework .ServiceReference ;
3233import org .osgi .service .component .ComponentContext ;
3334
3435import com .ibm .tx .jta .embeddable .UserTransactionDecorator ;
35- import com .ibm .tx .jta .embeddable .impl .EmbeddableUserTransactionImpl ;
3636import com .ibm .ws .container .service .naming .JavaColonNamingHelper ;
3737import com .ibm .ws .container .service .naming .NamingConstants .JavaColonNamespace ;
3838import com .ibm .ws .tx .embeddable .EmbeddableWebSphereUserTransaction ;
39- import com .ibm .ws .uow .embeddable .UOWManager ;
4039import com .ibm .wsspi .kernel .service .utils .AtomicServiceReference ;
4140
4241/**
@@ -97,20 +96,27 @@ protected void unsetUserTransactionDecorator(ServiceReference<UserTransactionDec
9796 @ Override
9897 public Object getObjectInstance (JavaColonNamespace namespace , String name ) throws NamingException {
9998 switch (namespace ) {
100- case COMP :
101- switch (name ) {
102- case "TransactionManager" : return getTransactionManager ();
103- case "TransactionSynchronizationRegistry" : return getTransactionSynchronizationRegistry ();
104- // If we have a service reference we know it's safe to return a reference
105- case "UserTransaction" : return userTranSvcRef == null ? null : getUserTransaction (false , null );
106- default : return null ;
107- }
108- case COMP_WS :
109- switch (name ) {
110- case "UOWManager" : return getUOWManager ();
111- default : return null ;
112- }
113- default : return null ;
99+ case COMP :
100+ switch (name ) {
101+ case "TransactionManager" :
102+ return getTransactionManager ();
103+ case "TransactionSynchronizationRegistry" :
104+ return getTransactionSynchronizationRegistry ();
105+ // If we have a service reference we know it's safe to return a reference
106+ case "UserTransaction" :
107+ return userTranSvcRef == null ? null : getUserTransaction (false , null );
108+ default :
109+ return null ;
110+ }
111+ case COMP_WS :
112+ switch (name ) {
113+ case "UOWManager" :
114+ return getUOWManager ();
115+ default :
116+ return null ;
117+ }
118+ default :
119+ return null ;
114120 }
115121 }
116122
@@ -130,27 +136,33 @@ public boolean hasObjectWithPrefix(JavaColonNamespace namespace, String name) th
130136 /** {@inheritDoc} */
131137 @ Override
132138 public Collection <? extends NameClassPair > listInstances (JavaColonNamespace namespace , String nameInContext ) {
133-
134- if (JavaColonNamespace .COMP .equals (namespace ) && "" .equals (nameInContext )) {
135- ArrayList <NameClassPair > retVal = new ArrayList <>();
136- if (userTranSvcRef != null ) {
137- NameClassPair pair = new NameClassPair (nameInContext , EmbeddableUserTransactionImpl .class .getName ());
138- retVal .add (pair );
139- }
140-
141- retVal .add (new NameClassPair (nameInContext , TransactionSynchronizationRegistry .class .getName ()));
142- retVal .add (new NameClassPair (nameInContext , UOWManager .class .getName ()));
143-
144- return retVal ;
145- } else {
139+ if (!"" .equals (nameInContext )) {
146140 return Collections .emptyList ();
147141 }
142+ switch (namespace ) {
143+ case COMP :
144+ ArrayList <NameClassPair > retVal = new ArrayList <>();
145+ if (userTranSvcRef != null ) {
146+ NameClassPair pair = new NameClassPair ("UserTransaction" , UserTransaction .class .getName ());
147+ retVal .add (pair );
148+ }
149+
150+ retVal .add (new NameClassPair ("TransactionSynchronizationRegistry" , TransactionSynchronizationRegistry .class .getName ()));
151+ retVal .add (new NameClassPair ("TransactionManager" , TransactionManager .class .getName ()));
152+
153+ return retVal ;
154+ case COMP_WS :
155+ // Using the API type for the class name here instead of non API type com.ibm.ws.uow.embeddable.UOWManager
156+ return Collections .singleton (new NameClassPair ("UOWManager" , com .ibm .wsspi .uow .UOWManager .class .getName ()));
157+ default :
158+ return Collections .emptyList ();
159+ }
148160 }
149161
150162 /**
151163 * Helper method for use with injection TransactionObjectFactoruy.
152164 *
153- * @param injection if the UserTransaction is being obtained for injection
165+ * @param injection if the UserTransaction is being obtained for injection
154166 * @param injectionContext the injection target context if injection is true, or null if unspecified
155167 * @return UserTransaction object with decorator applied if present
156168 * @throws NamingException if the decorator determines the UserTransaction is not available
@@ -165,4 +177,3 @@ protected UserTransaction getUserTransaction(boolean injection, Object injection
165177 }
166178 }
167179}
168-
0 commit comments