本文整理汇总了Java中org.jboss.resteasy.util.GetRestful类的典型用法代码示例。如果您正苦于以下问题:Java GetRestful类的具体用法?Java GetRestful怎么用?Java GetRestful使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GetRestful类属于org.jboss.resteasy.util包,在下文中一共展示了GetRestful类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExport
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
String addr = url.getIp() + ":" + url.getPort();
Class implClass = ServiceImplHolder.getInstance().popServiceImpl().getClass();
RestServer server = servers.get(addr);
if (server == null) {
server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
server.start(url);
servers.put(addr, server);
}
final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
server.deploy(resourceDef, impl, getContextPath(url));
final RestServer s = server;
return new Runnable() {
public void run() {
// TODO due to dubbo's current architecture,
// it will be called from registry protocol in the shutdown process and won't appear in logs
s.undeploy(resourceDef);
}
};
}
示例2: init
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
super.init(servletConfig);
Registry registry = getDispatcher().getRegistry();
ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
for (final Binding<?> binding : injector.getBindings().values()) {
Type type = binding.getKey().getTypeLiteral().getType();
if (type instanceof Class) {
Class<?> beanClass = (Class<?>) type;
if (GetRestful.isRootResource(beanClass)) {
ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
log.info("registering factory for {}", beanClass.getName());
registry.addResourceFactory(resourceFactory);
}
if (beanClass.isAnnotationPresent(Provider.class)) {
log.info("registering provider instance for {}", beanClass.getName());
providerFactory.registerProviderInstance(binding.getProvider().get());
}
}
}
}
示例3: doExport
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
String addr = url.getIp() + ":" + url.getPort();
Class implClass = ServiceClassHolder.getInstance().popServiceClass();
RestServer server = servers.get(addr);
if (server == null) {
server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
server.start(url);
servers.put(addr, server);
}
String contextPath = getContextPath(url);
if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, "jetty"))) {
ServletContext servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
if (servletContext == null) {
throw new RpcException("No servlet context found. Since you are using server='servlet', " +
"make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
}
String webappPath = servletContext.getContextPath();
if (StringUtils.isNotEmpty(webappPath)) {
webappPath = webappPath.substring(1);
if (!contextPath.startsWith(webappPath)) {
throw new RpcException("Since you are using server='servlet', " +
"make sure that the 'contextpath' property starts with the path of external webapp");
}
contextPath = contextPath.substring(webappPath.length());
if (contextPath.startsWith("/")) {
contextPath = contextPath.substring(1);
}
}
}
final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
server.deploy(resourceDef, impl, contextPath);
final RestServer s = server;
return new Runnable() {
public void run() {
// TODO due to dubbo's current architecture,
// it will be called from registry protocol in the shutdown process and won't appear in logs
s.undeploy(resourceDef);
}
};
}
示例4: resourcePackages
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
/**
* Returns a comma separated list of resource packages.
*/
private String resourcePackages() {
return injector.getBindings().keySet().stream()
.map(key -> key.getTypeLiteral().getRawType())
.filter(GetRestful::isRootResource)
.map(clazz -> clazz.getPackage().getName())
.distinct()
.collect(Collectors.joining(","));
}
示例5: init
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
logger.entry();
servletContainerDispatcher = new ServletContainerDispatcher();
FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
servletContext = servletConfig.getServletContext();
servletContainerDispatcher.init(servletContext, bootstrap, this, this);
servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);
if (injector == null)
injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());
Registry registry = getDispatcher().getRegistry();
ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
for (final Binding<?> binding : injector.getBindings().values()) {
Type type = binding.getKey().getTypeLiteral().getType();
if (type instanceof Class) {
Class<?> beanClass = (Class<?>) type;
if (GetRestful.isRootResource(beanClass)) {
ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
logger.info("registering factory for {}", beanClass.getName());
registry.addResourceFactory(resourceFactory);
}
if (beanClass.isAnnotationPresent(Provider.class)) {
logger.info("registering provider instance for {}", beanClass.getName());
providerFactory.registerProviderInstance(binding.getProvider().get());
}
}
}
logger.exit();
}
示例6: init
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
logger.entry();
servletContainerDispatcher = new ServletContainerDispatcher();
FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
servletContext = servletConfig.getServletContext();
servletContainerDispatcher.init(servletContext, bootstrap, this, this);
servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);
if(injector == null)
injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());
Registry registry = getDispatcher().getRegistry();
ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
for (final Binding<?> binding : injector.getBindings().values()) {
Type type = binding.getKey().getTypeLiteral().getType();
if (type instanceof Class) {
Class<?> beanClass = (Class<?>) type;
if (GetRestful.isRootResource(beanClass)) {
ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
logger.info("registering factory for {}", beanClass.getName());
registry.addResourceFactory(resourceFactory);
}
if (beanClass.isAnnotationPresent(Provider.class)) {
logger.info("registering provider instance for {}", beanClass.getName());
providerFactory.registerProviderInstance(binding.getProvider().get());
}
}
}
logger.exit();
}
示例7: doExport
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
String addr = url.getIp() + ":" + url.getPort();
Class implClass = ServiceClassHolder.getInstance().popServiceClass();
RestServer server = servers.get(addr);
if (server == null) {
server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
server.start(url);
servers.put(addr, server);
}
String contextPath = getContextPath(url);
if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, "jetty"))) {
ServletContext servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
if (servletContext == null) {
throw new RpcException("No servlet context found. Since you are using server='servlet', " +
"make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
}
String webappPath = servletContext.getContextPath();
if (StringUtils.isNotEmpty(webappPath)) {
webappPath = webappPath.substring(1);
if (!contextPath.startsWith(webappPath)) {
throw new RpcException("Since you are using server='servlet', " +
"make sure that the 'contextpath' property starts with the path of external webapp");
}
contextPath = contextPath.substring(webappPath.length());
if (contextPath.startsWith("/")) {
contextPath = contextPath.substring(1);
}
}
}
final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
// dubbo 服务多版本
String version = url.getParameter(Constants.VERSION_KEY);
if (StringUtils.isNotEmpty(version)) {
contextPath = version + "/" + contextPath;
}
server.deploy(resourceDef, impl, contextPath);
final RestServer s = server;
return new Runnable() {
public void run() {
// TODO due to dubbo's current architecture,
// it will be called from registry protocol in the shutdown process and won't appear in logs
s.undeploy(resourceDef);
}
};
}
示例8: doExport
import org.jboss.resteasy.util.GetRestful; //导入依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws JahhanException {
String addr = url.getIp() + ":" + url.getPort();
Class implClass = ServiceClassHolder.getInstance().popServiceClass();
RestServer server = servers.get(addr);
if (server == null) {
serverFactory.setHttpBinder(httpBinder);
server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, "jetty"));
server.start(url);
servers.put(addr, server);
}
String contextPath = getContextPath(url);
if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, "jetty"))) {
ServletContext servletContext = BaseContext.CTX.getServletContext(url.getPort());
if (servletContext == null) {
throw new JahhanException("No servlet context found. Since you are using server='servlet', "
+ "make sure that you've configured in web.xml");
}
String webappPath = servletContext.getContextPath();
if (StringUtils.isNotEmpty(webappPath)) {
webappPath = webappPath.substring(1);
if (!contextPath.startsWith(webappPath)) {
throw new JahhanException("Since you are using server='servlet', "
+ "make sure that the 'contextpath' property starts with the path of external webapp");
}
contextPath = contextPath.substring(webappPath.length());
if (contextPath.startsWith("/")) {
contextPath = contextPath.substring(1);
}
}
}
final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
server.deploy(resourceDef, impl, contextPath);
final RestServer s = server;
return new Runnable() {
public void run() {
// TODO due to dubbo's current architecture,
// it will be called from registry protocol in the shutdown
// process and won't appear in logs
s.undeploy(resourceDef);
}
};
}