com.khs.sherpa.endpoint.SherpaEndpoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of khs-sherpa Show documentation
Show all versions of khs-sherpa Show documentation
JSON remote data end point service via HTTP
package com.khs.sherpa.endpoint;
/*
* Copyright 2012 the original author or authors.
*
* Licensed 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.
*/
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.security.DenyAll;
import javax.annotation.security.RolesAllowed;
import org.apache.commons.lang3.StringUtils;
import org.reflections.ReflectionUtils;
import org.reflections.Reflections;
import com.google.common.base.Predicates;
import com.khs.sherpa.annotation.Action;
import com.khs.sherpa.annotation.Endpoint;
import com.khs.sherpa.annotation.Param;
import com.khs.sherpa.context.ApplicationContext;
import com.khs.sherpa.context.ApplicationContextAware;
import com.khs.sherpa.exception.NoSuchManagedBeanExcpetion;
import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.json.service.SessionTokenService;
import com.khs.sherpa.util.MethodUtil;
import com.khs.sherpa.util.SherpaPredicates;
@Endpoint(value = "Sherpa", authenticated = false)
public class SherpaEndpoint implements ApplicationContextAware {
private ApplicationContext applicationContext;
@RolesAllowed("SHERPA_ADMIN")
@Action(mapping = "/sherpa/admin/sessions")
public Object sessions(SessionTokenService service) {
return service.sessions();
}
@RolesAllowed("SHERPA_ADMIN")
@Action(mapping = "/sherpa/admin/endpoints")
public Map endpoints() {
Map map = new HashMap();
for(Entry entry: applicationContext.getEndpointTypes().entrySet()) {
String name = entry.getValue().getClass().getAnnotation(Endpoint.class).value();
if(StringUtils.isEmpty(name)) {
name = entry.getValue().getClass().getSimpleName();
}
map.put(name, entry.getValue().getClass().getName());
}
return map;
}
@SuppressWarnings("unchecked")
// @RolesAllowed("SHERPA_ADMIN")
@Action(mapping = "/sherpa/admin/describe/{value}")
public Object describe(@Param("value") String value) {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy