Skip to content

Commit

Permalink
Polish apache#3984 : Refactor implementation by the event/listener ab…
Browse files Browse the repository at this point in the history
…stract
  • Loading branch information
mercyblitz committed May 17, 2019
1 parent 18be1c9 commit dedca59
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.registry.client;
package org.apache.dubbo.common.utils;

import java.io.Serializable;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.registry.client;
package org.apache.dubbo.common.utils;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.registry.client;
package org.apache.dubbo.common.utils;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.dubbo.registry.client;

import org.apache.dubbo.common.utils.DefaultPage;
import org.apache.dubbo.common.utils.Page;
import org.apache.dubbo.registry.client.event.ServiceDiscoveryChangeListener;

import java.util.Collection;
Expand Down Expand Up @@ -99,9 +101,9 @@ public Page<ServiceInstance> getInstances(String serviceName, int offset, int re
}

@Override
public void registerListener(String serviceName, ServiceDiscoveryChangeListener listener) {
public void registerListener(ServiceDiscoveryChangeListener listener) {
for (ServiceDiscovery serviceDiscovery : serviceDiscoveries) {
serviceDiscovery.registerListener(serviceName, listener);
serviceDiscovery.registerListener(listener);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.dubbo.registry.client;

import org.apache.dubbo.common.utils.DefaultPage;
import org.apache.dubbo.common.utils.Page;
import org.apache.dubbo.registry.client.event.ServiceDiscoveryChangeListener;

import java.util.ArrayList;
Expand Down Expand Up @@ -162,10 +164,9 @@ default Map<String, Page<ServiceInstance>> getInstances(Iterable<String> service
/**
* Register {@link ServiceDiscoveryChangeListener the service chagne event listener}
*
* @param serviceName the name of service that is required to be listened
* @param listener {@link ServiceDiscoveryChangeListener the service change event listener}
*/
void registerListener(String serviceName, ServiceDiscoveryChangeListener listener);
void registerListener(ServiceDiscoveryChangeListener listener);

/**
* The priority of current {@link ServiceDiscovery}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.dubbo.registry.client.event;

import org.apache.dubbo.common.event.Event;
import org.apache.dubbo.registry.client.ServiceInstance;

import java.util.Collection;
Expand All @@ -27,10 +28,9 @@
* The Service Discovery Change {@link EventObject Event}
*
* @see ServiceDiscoveryChangeListener
* @see ServiceDiscoveryChangeEventNotifier
* @since 2.7.2
*/
public class ServiceDiscoveryChangeEvent extends EventObject {
public class ServiceDiscoveryChangeEvent extends Event {

private final String serviceName;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
*/
package org.apache.dubbo.registry.client.event;

import java.util.EventListener;
import org.apache.dubbo.common.event.EventListener;

/**
* The Service Discovery Change {@link EventListener Event Listener}
*
* @see ServiceDiscoveryChangeEvent
* @see ServiceDiscoveryChangeEventNotifier
* @since 2.7.2
*/
public interface ServiceDiscoveryChangeListener extends EventListener {
public interface ServiceDiscoveryChangeListener extends EventListener<ServiceDiscoveryChangeEvent> {

/**
* On {@link ServiceDiscoveryChangeEvent the service change event}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.registry.metadata;

import org.apache.dubbo.common.metadata.AbstractLocalMetadataService;
import org.apache.dubbo.common.metadata.MetadataService;
import org.apache.dubbo.registry.client.ServiceDiscovery;

/**
* {@link MetadataService} implementation works
*
* @since 2.7.2
*/
public class DiscoverableMetadataService extends AbstractLocalMetadataService {

private final ServiceDiscovery serviceDiscovery;

public DiscoverableMetadataService(String serviceName, ServiceDiscovery serviceDiscovery) {
super(serviceName);
this.serviceDiscovery = serviceDiscovery;
}

}
Loading

0 comments on commit dedca59

Please sign in to comment.