-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
1,018 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
dubbo-compatible/src/main/java/com/alibaba/dubbo/container/page/Menu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
dubbo-compatible/src/main/java/com/alibaba/dubbo/container/page/MenuComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
dubbo-compatible/src/main/java/com/alibaba/dubbo/container/page/Page.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
dubbo-compatible/src/main/java/com/alibaba/dubbo/container/page/PageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
Oops, something went wrong.