当前位置: 首页>>代码示例>>Java>>正文


Java Series.add方法代码示例

本文整理汇总了Java中org.restlet.util.Series.add方法的典型用法代码示例。如果您正苦于以下问题:Java Series.add方法的具体用法?Java Series.add怎么用?Java Series.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.util.Series的用法示例。


在下文中一共展示了Series.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRequestHeaders

import org.restlet.util.Series; //导入方法依赖的package包/类
@Override
public Series<Header> getRequestHeaders() {
    final Series<Header> result = super.getRequestHeaders();

    if (!this.requestHeadersAdded) {
        final Iterable<Map.Entry<String, String>> headers = getNettyRequest().headers();

        for (Map.Entry<String, String> header : headers) {
            result.add(header.getKey(), header.getValue());
        }

        this.requestHeadersAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:17,代码来源:NettyServerCall.java

示例2: getHeaders

import org.restlet.util.Series; //导入方法依赖的package包/类
@Override
public Series<Header> getHeaders() {
    final Series<Header> result = super.getHeaders();

    if (!this.headersAdded) {
        Entry<CharSequence, CharSequence> header = null;

        for (Iterator<Entry<CharSequence, CharSequence>> headers = getNettyRequest().headers()
                .iteratorCharSequence(); headers.hasNext();) {
            header = headers.next();
            result.add(header.getKey().toString(), header.getValue().toString());
        }

        getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,
                result);
        this.headersAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:21,代码来源:HttpServerRequest.java

示例3: addExtensionHeaders

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Adds extension headers if they are non-standard headers.
 * 
 * @param existingHeaders
 *            The headers to update.
 * @param additionalHeaders
 *            The headers to add.
 */
public static void addExtensionHeaders(Series<Header> existingHeaders,
        Series<Header> additionalHeaders) {
    if (additionalHeaders != null) {
        for (Header param : additionalHeaders) {
            if (STANDARD_HEADERS.contains(param.getName())) {
                // Standard headers that can't be overridden
                Context.getCurrentLogger()
                        .warn(
                                "Addition of the standard header \""
                                        + param.getName()
                                        + "\" is not allowed. Please use the equivalent property in the Restlet API.");
            } else if (UNSUPPORTED_STANDARD_HEADERS.contains(param
                    .getName())) {
                Context.getCurrentLogger()
                        .warn(
                                "Addition of the standard header \""
                                        + param.getName()
                                        + "\" is discouraged as a future version of the Restlet API will directly support it.");
                existingHeaders.add(param);
            } else {
                existingHeaders.add(param);
            }
        }
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:34,代码来源:HeaderUtils.java

示例4: extractMediaParams

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Extract the media parameters. Only leave as the quality parameter if
 * found. Modifies the parameters list.
 * 
 * @param parameters
 *            All the preference parameters.
 * @return The media parameters.
 */
protected Series<Parameter> extractMediaParams(Series<Parameter> parameters) {
    Series<Parameter> result = null;
    boolean qualityFound = false;
    Parameter param = null;

    if (parameters != null) {
        result = new Series<Parameter>(Parameter.class);

        for (final Iterator<Parameter> iter = parameters.iterator(); !qualityFound
                && iter.hasNext();) {
            param = iter.next();

            if (param.getName().equals("q")) {
                qualityFound = true;
            } else {
                iter.remove();
                result.add(param);
            }
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:32,代码来源:PreferenceReader.java

示例5: addAllowOrigin

import org.restlet.util.Series; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void addAllowOrigin()
{
    Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
    if (responseHeaders == null)
    {
        responseHeaders = new Series<>(Header.class);
        getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
    }
    responseHeaders.add("Access-Control-Allow-Origin", "*");
    responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
    responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
    responseHeaders.add("Access-Control-Allow-Credentials", "false");
    responseHeaders.add("Access-Control-Max-Age", "60");
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:16,代码来源:ServerResource.java

示例6: start

import org.restlet.util.Series; //导入方法依赖的package包/类
@Override
public void start() throws UnknownHostException {
	if (isEnabled) {
		final boolean isRunning = this.isRunning.getAndSet(true);
		if (!isRunning) {
			if (isEnabled && port <= 0) {
				this.isEnabled = false;
				TestServerConsole.log("Could not start RestService. Parameter missing: 'server.service.rest.port'", 1, TestServerServiceEnum.TEST_SERVER);
			}
			 
		    Component component = new Component();  

		    Server s = component.getServers().add(isSsl ? Protocol.HTTPS : Protocol.HTTP, InetAddress.getLocalHost().getHostAddress(), port);
		    
		    if (isSsl) {
			    Series<Parameter> parameters = s.getContext().getParameters();				    
			    parameters.add("keystorePath", QOS_KEY_FILE_ABSOLUTE);
			    parameters.add("keystorePassword", TestServer.QOS_KEY_PASSWORD);
			    parameters.add("keyPassword", TestServer.QOS_KEY_PASSWORD);
			    parameters.add("keystoreType", TestServer.QOS_KEY_TYPE);
		    }

		    component.getDefaultHost().attach("", new RestletApplication());
		    
		    try {
				component.start();
				TestServerConsole.log("[" + getName() + "] started: " + toString(), 1, TestServerServiceEnum.TEST_SERVER);
			} catch (Exception e) {
				TestServerConsole.error(getName(), e, 0, TestServerServiceEnum.TEST_SERVER);
			}  
		}
	}
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:34,代码来源:RestService.java

示例7: addAllowOrigin

import org.restlet.util.Series; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void addAllowOrigin()
{
    Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
    if (responseHeaders == null)
    {
        responseHeaders = new Series<Header>(Header.class);
        getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
    }
    responseHeaders.add("Access-Control-Allow-Origin", "*");
    responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
    responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
    responseHeaders.add("Access-Control-Allow-Credentials", "false");
    responseHeaders.add("Access-Control-Max-Age", "60");
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:16,代码来源:ServerResource.java

示例8: createRestletComponent

import org.restlet.util.Series; //导入方法依赖的package包/类
public OAuthEndpoint createRestletComponent() {
    emailExtensionApplication = new EmailExtensionApplication(tokenManager, extConfigManager);
    final OAuthEndpoint endpoint = new OAuthEndpoint(emailExtensionApplication);
    try {
        final URL url = new URL(extensionInfoData.getBaseUrl());
        final int port = url.getPort();
        if (Protocol.HTTP.getSchemeName().equals(url.getProtocol())) {
            if (port > 0) {
                endpoint.getServers().add(Protocol.HTTP, port);
            } else {
                endpoint.getServers().add(Protocol.HTTP);
            }
        } else if (Protocol.HTTPS.getSchemeName().equals(url.getProtocol())) {
            Server server;
            if (port > 0) {
                server = endpoint.getServers().add(Protocol.HTTPS, port);
            } else {
                server = endpoint.getServers().add(Protocol.HTTPS);
            }
            final Series<Parameter> parameters = server.getContext().getParameters();
            parameters.add("sslContextFactory", "org.restlet.engine.ssl.DefaultSslContextFactory");
            parameters.add("keyStorePath", extensionProperties.getSSLKeyStorePath());
            parameters.add("keyStorePassword", extensionProperties.getSSLKeyStorePassword());
            parameters.add("keyPassword", extensionProperties.getSSLKeyPassword());
            parameters.add("keyStoreType", extensionProperties.getSSLKeyStoreType());
        } else {
            logger.error("URL scheme {} not supported.  Not starting the email extension. ", url.getProtocol());
        }
    } catch (final MalformedURLException e) {
        logger.error("createRestletComponent error with base URL", e);
    }

    return endpoint;
}
 
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:35,代码来源:EmailEngine.java

示例9: read

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Reads all the entries.
 *
 * @return The form read.
 * @throws IOException
 *             If the entries could not be read.
 */
public Series<FormData> read() throws IOException {
    Series<FormData> result = new Series<FormData>(FormData.class);
    FormData entry = readNextEntry();

    while (entry != null) {
        result.add(entry);
        entry = readNextEntry();
    }

    this.stream.close();
    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:20,代码来源:FormReader.java

示例10: getResponseHeaders

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Returns the modifiable list of response headers.
 * 
 * @return The modifiable list of response headers.
 */
@Override
public Series<Header> getResponseHeaders() {
    Series<Header> result = super.getResponseHeaders();

    if (!this.responseHeadersAdded) {
        boolean loop = true;
        int i = 0;
        String headerName = null;
        String headerValue = null;

        while (loop) {
            try {
                headerName = getConnection().getHeaderFieldKey(i);
                headerValue = getConnection().getHeaderField(i);
            } catch (java.util.NoSuchElementException e) {
                // Some implementations especially the one for Google App
                // Engine throws a NoSuchElementException though this is not
                // stated by the contract of the abstract class
                // HttpUrlConnection.
                headerName = null;
            }
            if (headerName != null) {
                result.add(headerName, headerValue);
            } else {
                // As stated by the HttpUrlConnection javadocs, some
                // implementations may treat the 0th header field as
                // special, i.e. as the status line returned by the HTTP
                // server.
                loop = (i == 0);
            }
            i++;
        }

        this.responseHeadersAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:44,代码来源:HttpUrlConnectionCall.java

示例11: formatResponse

import org.restlet.util.Series; //导入方法依赖的package包/类
@Override
public void formatResponse(ChallengeWriter cw, ChallengeResponse challenge,
        Request request, Series<Header> httpHeaders) {

    // Setup the Date header
    String date = "";

    if (httpHeaders.getFirstValue("x-ms-date", true) == null) {
        // X-ms-Date header didn't override the standard Date header
        date = httpHeaders.getFirstValue(HeaderConstants.HEADER_DATE, true);

        if (date == null) {
            // Add a fresh Date header
            date = DateUtils.format(new Date(),
                    DateUtils.FORMAT_RFC_1123.get(0));
            httpHeaders.add(HeaderConstants.HEADER_DATE, date);
        }
    } else {
        date = httpHeaders.getFirstValue("x-ms-date", true);
    }

    // Setup the canonicalized path
    String canonicalizedResource = getCanonicalizedResourceName(request
            .getResourceRef());

    // Setup the message part
    StringBuilder rest = new StringBuilder();
    rest.append(date).append('\n').append('/')
            .append(challenge.getIdentifier())
            .append(canonicalizedResource);

    // Append the SharedKey credentials
    cw.append(challenge.getIdentifier())
            .append(':')
            .append(Base64.encode(
                    DigestUtils.toHMacSha256(rest.toString(),
                            Base64.decode(challenge.getSecret())), true));
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:39,代码来源:HttpAzureSharedKeyLiteHelper.java

示例12: addHeader

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Adds a header to the given list. Checks for exceptions and logs them.
 * 
 * @param headerName
 *            The header name.
 * @param headerValue
 *            The header value.
 * @param headers
 *            The headers list.
 */
public static void addHeader(String headerName, String headerValue,
        Series<Header> headers) {
    if ((headerName != null) && (headerValue != null)
            && (headerValue.length() > 0)) {
        try {
            headers.add(headerName, headerValue);
        } catch (Throwable t) {
            Context.getCurrentLogger().warn("Unable to format the " + headerName + " header", t);
        }
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:22,代码来源:HeaderUtils.java

示例13: keepExtensionHeadersOnly

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Copies extension headers into a request.
 * 
 * @param message
 *            The headers to copy.
 */
public static void keepExtensionHeadersOnly(Message message) {
    Series<Header> headers = message.getHeaders();
    Series<Header> extensionHeaders = new Series<Header>(Header.class);
    for (Header header : headers) {
        if (!STANDARD_HEADERS.contains(header.getName())) {
            extensionHeaders.add(header);
        }
    }
    message.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,
            extensionHeaders);
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:18,代码来源:HeaderUtils.java

示例14: copyExtensionHeaders

import org.restlet.util.Series; //导入方法依赖的package包/类
/**
 * Copies extension headers into a request or a response.
 * 
 * @param headers
 *            The headers to copy.
 * @param message
 *            The request or response to update.
 */
public static void copyExtensionHeaders(Series<Header> headers,
        Message message) {
    if (headers != null) {
        Series<Header> extensionHeaders = message.getHeaders();
        for (Header header : headers) {
            if (!STANDARD_HEADERS.contains(header.getName())) {
                extensionHeaders.add(header);
            }
        }
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:20,代码来源:HeaderUtils.java

示例15: run

import org.restlet.util.Series; //导入方法依赖的package包/类
public void run(FloodlightModuleContext fmlContext, String restHost) {
	setStatusService(new StatusService() {
		@Override
		public Representation getRepresentation(Status status,
				Request request,
				Response response) {
			return new JacksonRepresentation<Status>(status);
		}                
	});

	// Add everything in the module context to the rest
	for (Class<? extends IFloodlightService> s : fmlContext.getAllServices()) {
		if (logger.isTraceEnabled()) {
			logger.trace("Adding {} for service {} into context",
					s.getCanonicalName(), fmlContext.getServiceImpl(s));
		}
		context.getAttributes().put(s.getCanonicalName(), 
				fmlContext.getServiceImpl(s));
	}

	/*
	 * Specifically add the FML for use by the REST API's /wm/core/modules/...
	 */
	context.getAttributes().put(fmlContext.getModuleLoader().getClass().getCanonicalName(), fmlContext.getModuleLoader());

	/* Start listening for REST requests */
	try {
		final Component component = new Component();

		if (RestApiServer.useHttps) {
			Server server;

			if (restHost == null) {
				server = component.getServers().add(Protocol.HTTPS, Integer.valueOf(RestApiServer.httpsPort));
			} else {
				server = component.getServers().add(Protocol.HTTPS, restHost, Integer.valueOf(RestApiServer.httpsPort));
			}

			Series<Parameter> parameters = server.getContext().getParameters();
			//parameters.add("sslContextFactory", "org.restlet.ext.jsslutils.PkixSslContextFactory");
			parameters.add("sslContextFactory", "org.restlet.engine.ssl.DefaultSslContextFactory");

			parameters.add("keystorePath", RestApiServer.keyStore);
			parameters.add("keystorePassword", RestApiServer.keyStorePassword);
			parameters.add("keyPassword", RestApiServer.keyStorePassword);
			parameters.add("keystoreType", "JKS");

			parameters.add("truststorePath", RestApiServer.keyStore);
			parameters.add("truststorePassword", RestApiServer.keyStorePassword);
			parameters.add("trustPassword", RestApiServer.keyStorePassword);
			parameters.add("truststoreType", "JKS");

			parameters.add("needClientAuthentication", RestApiServer.httpsNeedClientAuth);
		}

		if (RestApiServer.useHttp) {
			if (restHost == null) {
				component.getServers().add(Protocol.HTTP, Integer.valueOf(RestApiServer.httpPort));
			} else {
				component.getServers().add(Protocol.HTTP, restHost, Integer.valueOf(RestApiServer.httpPort));
			}
		}

		component.getClients().add(Protocol.CLAP);
		component.getDefaultHost().attach(this);
		component.start();
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:71,代码来源:RestApiServer.java


注:本文中的org.restlet.util.Series.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。