Skip to content

Commit

Permalink
Fix #8843, recover Servlet Page API (#8884)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Sep 23, 2021
1 parent 7894430 commit 754404a
Show file tree
Hide file tree
Showing 10 changed files with 1,018 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 com.alibaba.dubbo.container.page;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Menu
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface Menu {

String name();

String desc() default "";

int order() default 0;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 com.alibaba.dubbo.container.page;

import java.io.Serializable;
import java.util.Comparator;

/**
* MenuComparator
*/
public class MenuComparator implements Comparator<PageHandler>, Serializable {

private static final long serialVersionUID = -3161526932904414029L;

@Override
public int compare(PageHandler o1, PageHandler o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return -1;
}
if (o2 == null) {
return 1;
}
return o1.equals(o2) ? 0 : (o1.getClass().getAnnotation(Menu.class).order()
> o2.getClass().getAnnotation(Menu.class).order() ? 1 : -1);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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 com.alibaba.dubbo.container.page;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Page
*/
public class Page {

private final String navigation;

private final String title;

private final List<String> columns;

private final List<List<String>> rows;

public Page(String navigation) {
this(navigation, (String) null, (String[]) null, (List<List<String>>) null);
}

public Page(String navigation, String title,
String column, String row) {
this(navigation, title, column == null ? null : Arrays.asList(new String[]{column}), row == null ? null : stringToList(row));
}

public Page(String navigation, String title,
String[] columns, List<List<String>> rows) {
this(navigation, title, columns == null ? null : Arrays.asList(columns), rows);
}

public Page(String navigation, String title,
List<String> columns, List<List<String>> rows) {
this.navigation = navigation;
this.title = title;
this.columns = columns;
this.rows = rows;
}

private static List<List<String>> stringToList(String str) {
List<List<String>> rows = new ArrayList<List<String>>();
List<String> row = new ArrayList<String>();
row.add(str);
rows.add(row);
return rows;
}

public String getNavigation() {
return navigation;
}

public String getTitle() {
return title;
}

public List<String> getColumns() {
return columns;
}

public List<List<String>> getRows() {
return rows;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 com.alibaba.dubbo.container.page;


import org.apache.dubbo.common.extension.SPI;

import com.alibaba.dubbo.common.URL;

/**
* PageHandler
*/
@SPI
public interface PageHandler {

/**
* Handle the page.
*
* @param url
* @return the page.
*/
Page handle(URL url);

}
Loading

0 comments on commit 754404a

Please sign in to comment.