Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse

Web Service is one of many well-defined extension points supported by the WSO2 Governance Registry. Read more on Supported Extension Points for a complete list of extension points supported by WSO2 Governance Registry.

...

Code Block
languagehtml/xml
<plugin>
    <groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<executions>
<execution>
<artifactId>maven<id>generate-scr-plugin</artifactId>scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>

4. Comment-out the following in your POM file:

...

Code Block
languagejava
package org.wso2.carbon.registry.samples.services;
  
import org.wso2.carbon.registry.core.service.RegistryService;
  
/**
 * @scr.component name="org.wso2.carbon.registry.samples.endpoint.lookup" immediate="true"
 * @scr.reference name="registryregistryService.service"
 * interface="org.wso2.carbon.registry.core.service.RegistryService"
 * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
 */
public class EndpointLookupServiceComponent {
  
    private static RegistryService registryService;
  
    protected void setRegistryService(RegistryService registryService) {
        EndpointLookupServiceComponent.registryService = registryService;
    }
  
    protected void unsetRegistryService(RegistryService registryService) {
        EndpointLookupServiceComponent.registryService = null;
    }
  
    public static RegistryService getRegistryService() {
        return registryService;
    }
}

...

Code Block
languagejava
package org.wso2.carbon.registry.samples.services;
  
import org.wso2.carbon.governance.api.exception.GovernanceException;
import org.wso2.carbon.governance.api.servicesgeneric.ServiceFilterGenericArtifactFilter;
import org.wso2.carbon.governance.api.servicesgeneric.dataobjects.ServiceManagerGenericArtifact;
import org.wso2.carbon.governance.api.servicesgeneric.dataobjects.ServiceGenericArtifactManager;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
  
import java.util.LinkedList;
import java.util.List;

/**
public class* EndpointLookupServiceThis {is the class used to implement the privateendpoint Registrylookup governanceRegistry;service.
 */
public class EndpointLookupService {
public   
    private Registry governanceRegistry;
  
    public EndpointLookupService() {
        try {
            governanceRegistry = EndpointLookupServiceComponent.getRegistryService()
                    .getGovernanceSystemRegistry();
        } catch (RegistryException e) {
            e.printStackTrace();
        }
    }

    /**
     *
     * @param serviceName       name of the service
     * @param serviceNamespace  name space of the servic
     * @param version           service version
     * @param environment       service endpoint environment
     * @return                  endpoints satisfies the given criteria
     * @throws GovernanceException
     * @throws RegistryException
   }  */
    public String[] getEndpoints(final String serviceName, final String serviceNamespace,
                                 final String version, final String environment)
            throws GovernanceException, RegistryException {

        ServiceManagerGenericArtifactManager manager = new ServiceManagerGenericArtifactManager(governanceRegistry,"service");
        ServiceGenericArtifact[] servicesartifacts = manager.findServicesfindGenericArtifacts(new ServiceFilterGenericArtifactFilter() {
            @Override
            public boolean matches(ServiceGenericArtifact servicegenericArtifact) throws GovernanceException {
                return serviceName.equals(servicegenericArtifact.getQName().getLocalPart()) &&
                        (serviceNamespace == null || serviceNamespace.length() == 0 ||
                                serviceNamespace.equals(servicegenericArtifact.getQName().getNamespaceURI())) &&
                        (version == null || version.length() == 0 ||
                                version.equals(servicegenericArtifact.getAttribute("overview_version")));
            }
        });
        if (servicesartifacts != null && servicesartifacts.length > 0) {
            List<String> endpoints = new LinkedList<String>();
            for (ServiceGenericArtifact serviceartifact : servicesartifacts) {
                String[] entries = serviceartifact.getAttributes("endpoints_entry");
                if (entries != null && entries.length > 0) {
                    for (String entry : entries) {
                        int idx = entry.indexOf(":");
                        if (entry.substring(0, idx).equals(environment)) {
                            endpoints.add(entry.substring(idx + 1));
                        }
                    }
                }
            }
            return endpoints.toArray(new String[endpoints.size()]);
        }
        return new String[0];
    }
}

...

9. Copy the GREG_HOME/ samples/handler/src/target/org.wso2.carbon.registry.samples.handler-4.6.0.jar into GREG_HOME/repository/components/dropins.

...