2626import org .slf4j .Logger ;
2727import org .slf4j .LoggerFactory ;
2828
29+ import java .util .Collection ;
2930import java .util .HashMap ;
3031import java .util .LinkedHashSet ;
3132import java .util .Map ;
@@ -111,10 +112,9 @@ public void exportService(ServiceReference serviceReference) {
111112 try {
112113 Thread .currentThread ().setContextClassLoader (getClass ().getClassLoader ());
113114
114- String exportedServices = (String ) serviceReference .getProperty (Constants .EXPORTED_INTERFACES );
115- if (exportedServices != null && exportedServices .length () > 0 ) {
116- LOGGER .debug ("CELLAR DOSGI: registering services {} in the cluster" , exportedServices );
117- String [] interfaces = exportedServices .split (Constants .INTERFACE_SEPARATOR );
115+ String [] interfaces = getExportedInterfaces (serviceReference );
116+ if (interfaces .length > 0 ) {
117+ LOGGER .debug ("CELLAR DOSGI: registering services {} in the cluster" , (Object ) interfaces );
118118 Object service = bundleContext .getService (serviceReference );
119119
120120 Set <String > exportedInterfaces = getServiceInterfaces (service , interfaces );
@@ -159,10 +159,9 @@ public void unExportService(ServiceReference serviceReference) {
159159 ClassLoader originalClassLoader = Thread .currentThread ().getContextClassLoader ();
160160 try {
161161 Thread .currentThread ().setContextClassLoader (getClass ().getClassLoader ());
162- String exportedServices = (String ) serviceReference .getProperty (Constants .EXPORTED_INTERFACES );
163- if (exportedServices != null && exportedServices .length () > 0 ) {
164- LOGGER .debug ("CELLAR DOSGI: un-register service {} from the cluster" , exportedServices );
165- String [] interfaces = exportedServices .split (Constants .INTERFACE_SEPARATOR );
162+ String [] interfaces = getExportedInterfaces (serviceReference );
163+ if (interfaces .length > 0 ) {
164+ LOGGER .debug ("CELLAR DOSGI: un-register service {} from the cluster" , (Object ) interfaces );
166165 Object service = bundleContext .getService (serviceReference );
167166
168167 Set <String > exportedInterfaces = getServiceInterfaces (service , interfaces );
@@ -188,6 +187,21 @@ public void unExportService(ServiceReference serviceReference) {
188187 }
189188 }
190189
190+
191+ private String [] getExportedInterfaces (ServiceReference serviceReference ) {
192+ Object property = serviceReference .getProperty (Constants .EXPORTED_INTERFACES );
193+ if (property != null ) {
194+ if (property instanceof String )
195+ return ((String ) property ).split (Constants .INTERFACE_SEPARATOR );
196+ if (property instanceof String [])
197+ return (String []) property ;
198+ if (property instanceof Collection )
199+ return (String [])((Collection ) property ).toArray ();
200+ LOGGER .warn ("CELLAR DOSGI: Illegal value type on property {} on service reference {}" , Constants .EXPORTED_INTERFACES , serviceReference );
201+ }
202+ return Constants .NO_EXPORTED_INTERFACES ;
203+ }
204+
191205 /**
192206 * Get the interfaces that match the exported service interfaces.
193207 *
0 commit comments