Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 1 | /* |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 17 | package org.apache.felix.shell.remote; |
| 18 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 19 | import org.apache.felix.shell.ShellService; |
Felix Meschberger | d7c324d | 2008-08-19 14:10:48 +0000 | [diff] [blame] | 20 | import org.osgi.framework.Bundle; |
| 21 | import org.osgi.framework.BundleContext; |
| 22 | import org.osgi.framework.Constants; |
| 23 | import org.osgi.framework.InvalidSyntaxException; |
| 24 | import org.osgi.framework.ServiceEvent; |
| 25 | import org.osgi.framework.ServiceListener; |
| 26 | import org.osgi.framework.ServiceReference; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 27 | import org.osgi.service.log.LogService; |
| 28 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 29 | /** |
| 30 | * Implements a mediator pattern class for services from the OSGi container. |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 31 | */ |
| 32 | class ServiceMediator |
| 33 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 34 | private BundleContext m_bundleContext; |
| 35 | private ShellService m_felixShellService; |
| 36 | private Latch m_felixShellServiceLatch; |
| 37 | private LogService m_logService; |
| 38 | private Latch m_logServiceLatch; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Returns a reference to the <tt>ShellService</tt> (Felix). |
| 42 | * |
| 43 | * @param wait time in milliseconds to wait for the reference if it isn't available. |
| 44 | * @return the reference to the <tt>ShellService</tt> as obtained from the OSGi service layer. |
| 45 | */ |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 46 | public ShellService getFelixShellService(long wait) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 47 | { |
| 48 | try |
| 49 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 50 | if (wait < 0) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 51 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 52 | m_felixShellServiceLatch.acquire(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 53 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 54 | else if (wait > 0) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 55 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 56 | m_felixShellServiceLatch.attempt(wait); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 57 | } |
| 58 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 59 | catch (InterruptedException e) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 60 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 61 | e.printStackTrace(System.err); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 64 | return m_felixShellService; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 65 | }//getFelixShellService |
| 66 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 67 | public LogService getLogServiceLatch(long wait) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 68 | { |
| 69 | try |
| 70 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 71 | if (wait < 0) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 72 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 73 | m_logServiceLatch.acquire(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 74 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 75 | else if (wait > 0) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 76 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 77 | m_logServiceLatch.attempt(wait); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 78 | } |
| 79 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 80 | catch (InterruptedException e) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 81 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 82 | e.printStackTrace(System.err); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 83 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 84 | return m_logService; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 85 | }//getLogService |
| 86 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 87 | public void info(String msg) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 88 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 89 | if (m_logService != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 90 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 91 | m_logService.log(LogService.LOG_INFO, msg); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 92 | } |
| 93 | else |
| 94 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 95 | sysout(msg); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 96 | } |
| 97 | }//info |
| 98 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 99 | public void error(String msg, Throwable t) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 100 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 101 | if (m_logService != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 102 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 103 | m_logService.log(LogService.LOG_ERROR, msg, t); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 104 | } |
| 105 | else |
| 106 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 107 | syserr(msg, t); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 108 | } |
| 109 | }//error |
| 110 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 111 | public void error(String msg) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 112 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 113 | if (m_logService != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 114 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 115 | m_logService.log(LogService.LOG_ERROR, msg); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 116 | } |
| 117 | else |
| 118 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 119 | syserr(msg, null); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 120 | } |
| 121 | }//error |
| 122 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 123 | public void debug(String msg) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 124 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 125 | if (m_logService != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 126 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 127 | m_logService.log(LogService.LOG_DEBUG, msg); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 128 | } |
| 129 | else |
| 130 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 131 | sysout(msg); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 132 | } |
| 133 | }//debug |
| 134 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 135 | public void warn(String msg) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 136 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 137 | if (m_logService != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 138 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 139 | m_logService.log(LogService.LOG_WARNING, msg); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 140 | } |
| 141 | else |
| 142 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 143 | syserr(msg, null); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 144 | } |
| 145 | }//warn |
| 146 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 147 | private void sysout(String msg) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 148 | { |
| 149 | //Assemble String |
| 150 | StringBuffer sbuf = new StringBuffer(); |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 151 | Bundle b = m_bundleContext.getBundle(); |
| 152 | sbuf.append(b.getHeaders().get(Constants.BUNDLE_NAME)); |
| 153 | sbuf.append(" ["); |
| 154 | sbuf.append(b.getBundleId()); |
| 155 | sbuf.append("] "); |
| 156 | sbuf.append(msg); |
| 157 | System.out.println(sbuf.toString()); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 158 | }//sysout |
| 159 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 160 | private void syserr(String msg, Throwable t) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 161 | { |
| 162 | //Assemble String |
| 163 | StringBuffer sbuf = new StringBuffer(); |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 164 | Bundle b = m_bundleContext.getBundle(); |
| 165 | sbuf.append(b.getHeaders().get(Constants.BUNDLE_NAME)); |
| 166 | sbuf.append(" ["); |
| 167 | sbuf.append(b.getBundleId()); |
| 168 | sbuf.append("] "); |
| 169 | sbuf.append(msg); |
| 170 | System.err.println(sbuf.toString()); |
| 171 | if (t != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 172 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 173 | t.printStackTrace(System.err); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 174 | } |
| 175 | }//logToSystem |
| 176 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 177 | /** |
| 178 | * Activates this mediator to start tracking the required services using the |
| 179 | * OSGi service layer. |
| 180 | * |
| 181 | * @param bc the bundle's context. |
| 182 | * @return true if activated successfully, false otherwise. |
| 183 | */ |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 184 | public boolean activate(BundleContext bc) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 185 | { |
| 186 | //get the context |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 187 | m_bundleContext = bc; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 188 | |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 189 | m_felixShellServiceLatch = createWaitLatch(); |
| 190 | m_logServiceLatch = createWaitLatch(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 191 | |
| 192 | //prepareDefinitions listener |
| 193 | ServiceListener serviceListener = new ServiceListenerImpl(); |
| 194 | |
Felix Meschberger | f543f37 | 2008-09-10 19:33:25 +0000 | [diff] [blame] | 195 | //prepareDefinitions the filter, ShellService is required, |
| 196 | //LogService may be missing, in which case we only use the |
| 197 | // ShellService part of the filter |
| 198 | String filter = "(objectclass=" + ShellService.class.getName() + ")"; |
| 199 | try |
| 200 | { |
| 201 | filter = "(|" + filter + "(objectclass=" + LogService.class.getName() + "))"; |
| 202 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 203 | catch (Throwable t) |
Felix Meschberger | f543f37 | 2008-09-10 19:33:25 +0000 | [diff] [blame] | 204 | { |
| 205 | // ignore |
| 206 | } |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 207 | |
| 208 | try |
| 209 | { |
| 210 | //add the listener to the bundle context. |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 211 | bc.addServiceListener(serviceListener, filter); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 212 | |
| 213 | //ensure that already registered Service instances are registered with |
| 214 | //the manager |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 215 | ServiceReference[] srl = bc.getServiceReferences(null, filter); |
| 216 | for (int i = 0; srl != null && i < srl.length; i++) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 217 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 218 | serviceListener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, srl[i])); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 219 | } |
| 220 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 221 | catch (InvalidSyntaxException ex) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 222 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 223 | ex.printStackTrace(System.err); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 224 | return false; |
| 225 | } |
| 226 | return true; |
| 227 | }//activate |
| 228 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 229 | /** |
| 230 | * Deactivates this mediator, nulling out all references. |
| 231 | * If called when the bundle is stopped, the framework should actually take |
| 232 | * care of unregistering the <tt>ServiceListener</tt>. |
| 233 | */ |
| 234 | public void deactivate() |
| 235 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 236 | m_felixShellService = null; |
| 237 | m_felixShellServiceLatch = null; |
| 238 | m_bundleContext = null; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 239 | }//deactivate |
| 240 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 241 | /** |
| 242 | * Creates a simple wait latch to be used for the mechanism that allows entities |
| 243 | * in the bundles to wait for references. |
| 244 | * |
| 245 | * @return a new Latch instance. |
| 246 | */ |
| 247 | private Latch createWaitLatch() |
| 248 | { |
| 249 | return new Latch(); |
| 250 | }//createWaitLatch |
| 251 | |
| 252 | /** |
| 253 | * The <tt>ServiceListener</tt> implementation. |
| 254 | */ |
| 255 | private class ServiceListenerImpl implements ServiceListener |
| 256 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 257 | public void serviceChanged(ServiceEvent ev) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 258 | { |
| 259 | ServiceReference sr = ev.getServiceReference(); |
| 260 | Object o = null; |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 261 | switch (ev.getType()) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 262 | { |
| 263 | case ServiceEvent.REGISTERED: |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 264 | o = m_bundleContext.getService(sr); |
| 265 | if (o == null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 266 | { |
| 267 | return; |
| 268 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 269 | else if (o instanceof ShellService) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 270 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 271 | m_felixShellService = (ShellService) o; |
| 272 | m_felixShellServiceLatch.release(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 273 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 274 | else if (o instanceof LogService) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 275 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 276 | m_logService = (LogService) o; |
| 277 | m_logServiceLatch.release(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 278 | } |
| 279 | else |
| 280 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 281 | m_bundleContext.ungetService(sr); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 282 | } |
| 283 | break; |
| 284 | case ServiceEvent.UNREGISTERING: |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 285 | o = m_bundleContext.getService(sr); |
| 286 | if (o == null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 287 | { |
| 288 | return; |
| 289 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 290 | else if (o instanceof ShellService) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 291 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 292 | m_felixShellService = null; |
| 293 | m_felixShellServiceLatch = createWaitLatch(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 294 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 295 | else if (o instanceof LogService) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 296 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 297 | m_logService = null; |
| 298 | m_logServiceLatch = createWaitLatch(); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 299 | } |
| 300 | else |
| 301 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame^] | 302 | m_bundleContext.ungetService(sr); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 303 | } |
| 304 | break; |
| 305 | } |
| 306 | } |
| 307 | }//inner class ServiceListenerImpl |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 308 | public static long WAIT_UNLIMITED = -1; |
| 309 | public static long NO_WAIT = 0; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 310 | }//class ServiceMediator |