Package org.eclipse.ecf.core.identity

Examples of org.eclipse.ecf.core.identity.ID


   * @since 2.0
   */
  protected boolean matchHostContainerID(ServiceReference serviceReference,
      Map<String, Object> properties, IContainer container) {

    ID containerID = container.getID();
    // No match if the container has no ID
    if (containerID == null)
      return false;

    // Then get containerid if specified directly by user in properties
    ID requiredContainerID = (ID) properties
        .get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_ID);
    // If the CONTAINER_I
    if (requiredContainerID != null) {
      return requiredContainerID.equals(containerID);
    }
    // Else get the container factory arguments, create an ID from the
    // arguments
    // and check if the ID matches that
    Namespace ns = containerID.getNamespace();
    Object cid = properties
        .get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS);
    // If no arguments are present, then any container ID should match
    if (cid == null)
      return true;
    ID cID = null;
    if (cid instanceof ID) {
      cID = (ID) cid;
    } else if (cid instanceof String) {
      cID = IDUtil.createID(ns, (String) cid);
    } else if (cid instanceof Object[]) {
View Full Code Here


   * @since 2.0
   */
  protected void connectHostContainer(ServiceReference serviceReference,
      Map<String, Object> properties, IContainer container, Object target)
      throws ContainerConnectException, IDCreateException {
    ID targetID = (target instanceof String) ? IDUtil.createID(
        container.getConnectNamespace(), (String) target) : IDUtil
        .createID(container.getConnectNamespace(),
            new Object[] { target });
    Object context = properties
        .get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT);
View Full Code Here

    if (target == null)
      return true;
    // If a targetID is specified, make sure it either matches what the
    // container
    // is already connected to, or that we connect an unconnected container
    ID connectedID = container.getConnectedID();
    // If the container is not already connected to anything
    // then we connect it to the given target
    if (connectedID == null) {
      // connect to the target and we have a match
      try {
        connectHostContainer(serviceReference, properties, container,
            target);
      } catch (Exception e) {
        logException("doConnectContainer containerID=" //$NON-NLS-1$
            + container.getID() + " target=" + target, e); //$NON-NLS-1$
        return false;
      }
      return true;
    } else {
      ID targetID = createTargetID(container, target);
      // We check here if the currently connectedID equals the target.
      // If it does we have a match
      if (connectedID.equals(targetID))
        return true;
    }
View Full Code Here

  public static final void main(String[] args) throws Exception {
    ISharedObjectContainerConfig config = new SOContainerConfig(IDFactory.getDefault().createGUID());
    SSLClientSOContainer container = new SSLClientSOContainer(config);
    // now join group
    ID serverID = IDFactory.getDefault().createStringID(SSLServerSOContainer.getDefaultServerURL());
    container.connect(serverID, null);
    Thread.sleep(200000);
  }
View Full Code Here

   * @see
   * org.eclipse.ecf.internal.remoteservices.ui.handlers.ConnectionHandler
   * #getJob()
   */
  protected Job getJob(final ExecutionEvent event) throws ExecutionException {
    final ID createConnectId = RemoteServiceHandlerUtil
        .getActiveConnectIDChecked(event);
    final IContainer container = RemoteServiceHandlerUtil
        .getActiveIRemoteServiceContainerChecked(event);
    // decouple the long running connect call from the ui thread
    return new Job(NLS.bind("Connecting {0}", createConnectId.getName())) {
      protected IStatus run(IProgressMonitor monitor) {
        if (container == null)
          return Status.OK_STATUS;
        container.disconnect();
        return Status.OK_STATUS;
View Full Code Here

import org.eclipse.osgi.util.NLS;

public class ConnectRemoteServicehandler extends ConnectionHandler {

  protected Job getJob(final ExecutionEvent event) throws ExecutionException {
    final ID createConnectId = RemoteServiceHandlerUtil
        .getActiveConnectIDChecked(event);
    final IContainer container = RemoteServiceHandlerUtil
        .getActiveIRemoteServiceContainerChecked(event);
    // decouple the long running connect call from the ui thread
    return new Job(NLS.bind("Connecting {0}", createConnectId.getName())) {
      protected IStatus run(IProgressMonitor monitor) {
        try {
          if (container != null)
            container.connect(createConnectId, null);
        } catch (ContainerConnectException e) {
View Full Code Here

        objectMap = new HashMap<ID, IBBObject>();
      }
    }
    while (m.find()) {
      final Map<String, Object> values = pattern.getValueMap(m);
      ID id = null;
      try {
        id = factory.createBBObjectId(namespace, baseURL, (String) values.get(IPatternDescriptor.ID_PARAM));
      } catch (final IDCreateException e) {
        // TODO autogen e
        e.printStackTrace();
View Full Code Here

          // If not in correct state, disconnect and return
          if (getConnection() != aConnection) {
            disconnect(aConnection);
            throw new IllegalStateException("Container connect failed because not in correct state"); //$NON-NLS-1$
          }
          ID serverID = null;
          try {
            serverID = handleConnectResponse(targetID, response);
          } catch (final Exception e) {
            setStateDisconnected(aConnection);
            throw e;
View Full Code Here

  protected void handleLeaveGroupMessage(ContainerMessage mess) {
    if (!isConnected())
      return;
    final ContainerMessage.LeaveGroupMessage lgm = (ContainerMessage.LeaveGroupMessage) mess.getData();
    final ID fromID = mess.getFromContainerID();
    if (fromID == null || !fromID.equals(remoteServerID)) {
      // we ignore anything not from our server
      return;
    }
    synchronized (getGroupMembershipLock()) {
      handleLeave(fromID, connection);
View Full Code Here

    if (!isConnected())
      return;
    final ContainerMessage.ViewChangeMessage vc = (ContainerMessage.ViewChangeMessage) mess.getData();
    if (vc == null)
      throw new IOException("view change message cannot be null"); //$NON-NLS-1$
    final ID fromID = mess.getFromContainerID();
    if (fromID == null || !fromID.equals(remoteServerID)) {
      throw new IOException("view change message fromID=" + fromID + " is not from remoteServerID=" + remoteServerID); //$NON-NLS-1$ //$NON-NLS-2$
    }
    final ID[] changeIDs = vc.getChangeIDs();
    if (changeIDs == null) {
      // do nothing if we've got no changes
    } else {
      for (int i = 0; i < changeIDs.length; i++) {
        if (vc.isAdd()) {
          boolean wasAdded = false;
          synchronized (getGroupMembershipLock()) {
            // check to make sure this member id is not already
            // known
            if (groupManager.getMemberForID(changeIDs[i]) == null) {
              wasAdded = true;
              groupManager.addMember(new Member(changeIDs[i]));
            }
          }
          // Notify listeners only if the add was actually
          // accomplished
          if (wasAdded)
            fireContainerEvent(new ContainerConnectedEvent(getID(), changeIDs[i]));
        } else {
          if (changeIDs[i].equals(getID())) {
            // We've been ejected.
            final ID serverID = remoteServerID;
            synchronized (getGroupMembershipLock()) {
              handleLeave(remoteServerID, connection);
            }
            // Notify listeners that we've been ejected
            fireContainerEvent(new ContainerEjectedEvent(getID(), serverID, vc.getData()));
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.core.identity.ID

Copyright © 2018 www.massapicom. 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.