Package org.apache.muse.ws.dm.muws

Examples of org.apache.muse.ws.dm.muws.Relationships


    }
  }

  private void handleBundleDependencies(BundleContribution contribution, WsResource resource){
    try {
      Relationships relCap = (Relationships)resource.getCapability(MuwsConstants.RELATIONSHIPS_URI);
      if(relCap == null){
        return;
      }
      BundleContribution[] dependencies = contribution.getBundleDependents();
      if(dependencies == null) return;
      for(int i=0;i<dependencies.length;i++){
        BundleContribution dependency = dependencies[i];
        WsResource targetResource = (WsResource)resourceForContribution.get(dependency);
        if(targetResource == null){
          continue;
        }
        Participant[] participants = new Participant[2];
        QName typeNames[] = {new QName("http://resource.management.osgi/Bundle","Requires","osgi")};
        RelationshipType type = new SimpleRelationshipType(typeNames);
        participants[0] = new SimpleParticipant(resource, "required");
        participants[1] = new SimpleParticipant(targetResource, "requires");
        relCap.addRelationship("Bundle Requirement", type, participants);
      }
    } catch(Throwable t){
      t.printStackTrace();
    }
  }
View Full Code Here


    }
  }

  private void handleServiceRelationships(ServiceContribution contribution, WsResource resource){
    try {
      Relationships relCap = (Relationships)resource.getCapability(MuwsConstants.RELATIONSHIPS_URI);
      if(relCap == null) return;

      BundleContribution provider = contribution.getServiceProvider();
      if(provider != null){
        WsResource targetResource = (WsResource)resourceForContribution.get(provider);
        if(targetResource != null){
          Participant[] participants = new Participant[2];
          QName typeNames[] = {new QName("http://resource.management.osgi/Service","ServiceProvider","osgi")};
          RelationshipType type = new SimpleRelationshipType(typeNames);
          participants[0] = new SimpleParticipant(resource, "service");
          participants[1] = new SimpleParticipant(targetResource, "provider");
          relCap.addRelationship("ServiceConsumer", type, participants);

          //Now add reciprocal relationship to the bundle resource
          relCap = (Relationships)targetResource.getCapability(MuwsConstants.RELATIONSHIPS_URI);
          participants = new Participant[2];
          QName serviceTypeNames[] = {new QName("http://resource.management.osgi/Bundle","RegisteredService","osgi")};
          type = new SimpleRelationshipType(serviceTypeNames);
          participants[0] = new SimpleParticipant(resource, "service");
          participants[1] = new SimpleParticipant(targetResource, "provider");
          relCap.addRelationship("RegisteredService", type, participants);
        }
      }

      BundleContribution[] consumers = contribution.getServiceConsumers();
      if(consumers == null) return;
      for(int i=0;i<consumers.length;i++){
        BundleContribution dependency = consumers[i];
        WsResource targetResource = (WsResource)resourceForContribution.get(dependency);
        if(targetResource == null){
          continue;
        }
        Participant[] participants = new Participant[2];
        QName typeNames[] = {new QName("http://resource.management.osgi/Service","ServiceConsumer")};
        RelationshipType type = new SimpleRelationshipType(typeNames);
        participants[0] = new SimpleParticipant(resource, "service");
        participants[1] = new SimpleParticipant(targetResource, "consumer");
        relCap.addRelationship("Service Consumer", type, participants);
      }
    } catch(Throwable t){
      t.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.muse.ws.dm.muws.Relationships

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.