Examples of EndpointListener


Examples of org.osgi.service.remoteserviceadmin.EndpointListener

    }
   
    public void testClearTracker() throws Exception {
        LocalDiscovery ld = getLocalDiscovery();
       
        EndpointListener el = EasyMock.createMock(EndpointListener.class);
        ld.listenerToFilters.put(el, new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
        ld.filterToListeners.put("(a=b)", new ArrayList<EndpointListener>(Arrays.asList(el)));
        ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)", new ArrayList<EndpointListener>(Arrays.asList(el)));
                       
        ld.clearTracker("foobar"); // should not barf
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

        // LOG
        // .info("TopologyManager: notifyListenerOfAddingIfAppropriate() called for own listener -> skipping ");
        // return;
        // }

        EndpointListener epl = (EndpointListener)bctx.getService(sref);

        LOG.info("TopologyManager: notifyListenerOfAddingIfAppropriate() ");

        try {

            List<Filter> filters = Utils.normalizeScope(sref, bctx);

            for (ExportRegistration exReg : exportRegistrations) {

                // FIXME!!!!!!!!!!!!! There needs to be a better way ?!?!?!
                Map props = exReg.getExportReference().getExportedEndpoint().getProperties();
                Dictionary d = new Hashtable(props);

                for (Filter filter : filters) {
                    LOG.info("Matching: " + filter + "  against " + d);
                }

                for (Filter filter : filters) {
                    if (filter.match(d)) {
                        LOG.info("Listener mached one of the Endpoints !!!!: " + epl);

                        epl
                            .endpointAdded(exReg.getExportReference().getExportedEndpoint(), filter
                                .toString());
                    }
                }
            }
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

    }

    protected void notifyListenersOfRemovalIfAppropriate(ServiceReference sref,
                                                         Collection<ExportRegistration> exportRegistrations) {

        EndpointListener epl = (EndpointListener)bctx.getService(sref);

        LOG.info("TopologyManager: notifyListenerOfREMOVALIfAppropriate() ");

        List<Filter> filters;
        try {
            filters = Utils.normalizeScope(sref, bctx);

            for (ExportRegistration exReg : exportRegistrations) {

                // FIXME!!!!!!!!!!!!! There needs to be a better way ?!?!?!
                Map props = exReg.getExportReference().getExportedEndpoint().getProperties();
                Dictionary d = new Hashtable(props);

                for (Filter filter : filters) {
                    LOG.info("Matching: " + filter + "  against " + d);
                }

                for (Filter filter : filters) {
                    if (filter.match(d)) {
                        LOG.info("Listener matched one of the Endpoints !!!! --> calling removed() ...");

                        epl.endpointRemoved(exReg.getExportReference().getExportedEndpoint(), filter
                            .toString());
                    }
                }
            }
        } catch (InvalidSyntaxException e) {
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

            //notifyListeners(epd, true);

            for (ServiceReference sref : discoveredServiceTracker.relatedServiceListeners) {
                if (bctx.getService(sref) instanceof EndpointListener) {
                    EndpointListener epl = (EndpointListener)bctx.getService(sref);

                    // return the >first< matching scope of the listener
                    // TODO: this code also exists for the endpoint adding in the processChild() method ->
                    // refactor !
                    String[] scopes = Util.getScopes(sref);
                    for (final String currentScope : scopes) {
                        LOG.fine("matching " + epd + " against " + currentScope);
                        Filter f = null;
                        try {
                            f = FrameworkUtil.createFilter(currentScope);

                            Dictionary d = new Properties();
                            Set<Map.Entry<String, Object>> entries = props.entrySet();
                            for (Map.Entry<String, Object> entry : entries) {
                                d.put(entry.getKey(), entry.getValue());
                            }

                            if (f.match(d)) {
                                LOG.fine("MATCHED " + epd + "against " + currentScope);
                                LOG.info("calling EndpointListener endpointRemoved: " + epl + "from bundle "
                                         + sref.getBundle().getSymbolicName() + " for endpoint: " + epd);

                                epl.endpointRemoved(epd, currentScope);
                                break;
                            }
                        } catch (InvalidSyntaxException e) {
                            e.printStackTrace();
                        }
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

        System.out.println("****************  notifyListeners("+epd+"  ,  "+isRemoval+")");
       
        for (ServiceReference sref : discoveredServiceTracker.relatedServiceListeners) {
            if (bctx.getService(sref) instanceof EndpointListener) {
                final EndpointListener epl = (EndpointListener)bctx.getService(sref);

                String[] scopes = Util.getScopes(sref);
                for (final String currentScope : scopes) {
                    Filter f;
                    try {
                        f = FrameworkUtil.createFilter(currentScope);

                        Dictionary d = new Properties();
                        Map<String, Object> props = epd.getProperties();
                        Set<Map.Entry<String, Object>> entries = props.entrySet();
                        for (Map.Entry<String, Object> entry : entries) {
                            d.put(entry.getKey(), entry.getValue());
                        }

                        LOG.fine("matching " + epd + " against " + currentScope);

                        if (f.match(d)) {
                            LOG.fine("MATCHED " + epd + "against " + currentScope);

                            LOG.info("scheduling EndpointListener call for listener ; " + epl
                                     + "  from bundle  " + sref.getBundle().getSymbolicName()
                                     + " based on scope [" + currentScope + "]");

                            if (isRemoval)
                                epl.endpointRemoved(epd, currentScope);
                            else
                                epl.endpointAdded(epd, currentScope);

                            break;
                        }
                    } catch (InvalidSyntaxException e) {
                        LOG.warning("skipping scope [" + currentScope
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

        return props;
    }

    private void cacheTracker(ServiceReference reference, Object service) {
        if (service instanceof EndpointListener) {
            EndpointListener listener = (EndpointListener)service;
            Collection<String> filters = null;
            synchronized (this) {
                filters = addTracker(reference, listener, EndpointListener.ENDPOINT_LISTENER_SCOPE);
                // Take a snapshot of the endpoints
                triggerCallbacks(null, filters, listener);
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

        }
    }

    private void updateTracker(ServiceReference reference, Object service) {
        if (service instanceof EndpointListener) {
            EndpointListener listener = (EndpointListener)service;
            Collection<String> oldFilters = null;
            Collection<String> newFilters = null;
            synchronized (this) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("updating listener: " + listener);
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

          Object listenerObject, int eventAction, Object eventObject) {
        final String logMethodName = "dispatchEvent"; //$NON-NLS-1$
        // We now dispatch both EndpointListenerEvents
        if (eventObject instanceof EndpointListenerEvent) {
          final EndpointListenerEvent event = (EndpointListenerEvent) eventObject;
          final EndpointListener endpointListener = event
              .getEndpointListener();
          final EndpointDescription endpointDescription = event
              .getEndointDescription();
          final String matchingFilter = event.getMatchingFilter();

          try {
            boolean discovered = event.isDiscovered();
            trace("endpointListener.discovered=" + discovered +" ", "fwk=" + getFrameworkUUID() + ", endpointListener=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                    + endpointListener
                    + ", endpointDescription=" //$NON-NLS-1$
                    + endpointDescription
                    + ", matchingFilter=" //$NON-NLS-1$
                    + matchingFilter);
            if (discovered)
              endpointListener.endpointAdded(endpointDescription,
                  matchingFilter);
            else
              endpointListener.endpointRemoved(
                  endpointDescription, matchingFilter);
          } catch (Exception e) {
            String message = "Exception in EndpointListener listener=" //$NON-NLS-1$
                + endpointListener + " description=" //$NON-NLS-1$
                + endpointDescription + " matchingFilter=" //$NON-NLS-1$
                + matchingFilter;
            logError(logMethodName, message, e);
          } catch (LinkageError e) {
            String message = "LinkageError in EndpointListener listener=" //$NON-NLS-1$
                + endpointListener + " description=" //$NON-NLS-1$
                + endpointDescription + " matchingFilter=" //$NON-NLS-1$
                + matchingFilter;
            logError(logMethodName, message, e);
          } catch (AssertionError e) {
            String message = "AssertionError in EndpointListener listener=" //$NON-NLS-1$
                + endpointListener + " description=" //$NON-NLS-1$
                + endpointDescription + " matchingFilter=" //$NON-NLS-1$
                + matchingFilter;
            logError(logMethodName, message, e);
          }
        // and EndpointEventListenerEvents
        } else if (eventObject instanceof EndpointEventListenerEvent) {
          final EndpointEventListenerEvent event = (EndpointEventListenerEvent) eventObject;
          final EndpointEventListener endpointEventListener = event.getEndpointEventListener();
          final EndpointEvent endpointEvent = event.getEndpointEvent();
          final String matchingFilter = event.getMatchingFilter();
          try {
            trace("endpointEventListener.discovered=" + getEndpointEventTypeAsString(endpointEvent.getType()) + " ", "fwk=" + getFrameworkUUID() + ", endpointEventListener=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                    + endpointEventListener
                    + ", endpointEvent=" //$NON-NLS-1$
                    + endpointEvent + ", matchingFilter=" //$NON-NLS-1$
                    + matchingFilter);
            endpointEventListener.endpointChanged(endpointEvent,
                matchingFilter);
          } catch (Exception e) {
            String message = "Exception in EndpointEventListener listener=" //$NON-NLS-1$
                + endpointEventListener + " event=" //$NON-NLS-1$
                + endpointEvent + " matchingFilter=" //$NON-NLS-1$
                + matchingFilter;
            logError(logMethodName, message, e);
          } catch (LinkageError e) {
            String message = "LinkageError in EndpointEventListener listener=" //$NON-NLS-1$
                + endpointEventListener + " event=" //$NON-NLS-1$
                + endpointEvent + " matchingFilter=" //$NON-NLS-1$
                + matchingFilter;
            logError(logMethodName, message, e);
          } catch (AssertionError e) {
            String message = "AssertionError in EndpointEventListener listener=" //$NON-NLS-1$
                + endpointEventListener + " event=" //$NON-NLS-1$
                + endpointEvent + " matchingFilter=" //$NON-NLS-1$
                + matchingFilter;
            logError(logMethodName, message, e);
           
          }
        }
      }
    });
    // Register the endpoint listener tracker, so that endpoint listeners
    // that are subsequently added
    // will then be notified of discovered endpoints
    endpointListenerTracker = new ServiceTracker(context,
        EndpointListener.class.getName(),
        new ServiceTrackerCustomizer() {
          public Object addingService(ServiceReference reference) {
            if (context == null)
              return null;
            EndpointListener listener = (EndpointListener) context
                .getService(reference);
            if (listener == null)
              return null;
            Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> allDiscoveredEndpointDescriptions = getAllDiscoveredEndpointDescriptions();
            for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : allDiscoveredEndpointDescriptions) {
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

      ServiceReference[] refs, EndpointDescription description) {
    if (refs == null)
      return null;
    List results = new ArrayList();
    for (int i = 0; i < refs.length; i++) {
      EndpointListener listener = (EndpointListener) context
          .getService(refs[i]);
      if (listener == null)
        continue;
      List<String> filters = PropertiesUtil.getStringPlusProperty(
          getMapFromProperties(refs[i]),
View Full Code Here

Examples of org.osgi.service.remoteserviceadmin.EndpointListener

import junit.framework.TestCase;

public class EndpointListenerTest extends TestCase {

  private EndpointListener createEndpointListener() {
    return new EndpointListener() {

      public void endpointAdded(EndpointDescription endpoint,
          String matchedFilter) {
        System.out.println("endpointAdded endpoint="+endpoint+",matchedFilter="+matchedFilter);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.