本文整理汇总了Java中org.apache.cxf.io.CachedOutputStream.writeCacheTo方法的典型用法代码示例。如果您正苦于以下问题:Java CachedOutputStream.writeCacheTo方法的具体用法?Java CachedOutputStream.writeCacheTo怎么用?Java CachedOutputStream.writeCacheTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.io.CachedOutputStream
的用法示例。
在下文中一共展示了CachedOutputStream.writeCacheTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
try
{
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(this.getClass().getResourceAsStream("/nl/clockwork/mule/ebms/xsl/EbMSNullTransformation.xml")));
transformer.transform(new StreamSource(new StringReader(sb.toString())),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
示例2: toString
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
private String toString(InputStream is) throws IOException {
StringBuilder out = new StringBuilder();
CachedOutputStream os = new CachedOutputStream();
IOHelper.copy(is, os);
is.close();
os.writeCacheTo(out);
return out.toString();
}
示例3: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault
{
String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
if (!method.equals("POST"))
{
return;
}
StringBuilder sb = new StringBuilder();
InputStream is = message.getContent(InputStream.class);
if (is != null)
{
CachedOutputStream bos = new CachedOutputStream();
try
{
copy(is, bos, 4096);
bos.flush();
is.close();
message.setContent(InputStream.class, bos.getInputStream());
bos.writeCacheTo(sb);
bos.close();
}
catch (IOException e)
{
throw new Fault(e);
}
}
if (!sb.toString().contains("http://www.w3.org/2005/08/addressing"))
{
throw new Fault("Could not find any reference to namespace 'http://www.w3.org/2005/08/addressing' in handled message.",
java.util.logging.Logger.getLogger(CheckInterceptor.class.getName()));
}
}
示例4: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault
{
String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
if (!method.equals("POST"))
{
return;
}
StringBuilder sb = new StringBuilder();
InputStream is = message.getContent(InputStream.class);
if (is != null)
{
CachedOutputStream bos = new CachedOutputStream();
try
{
copy(is, bos, 4096);
bos.flush();
is.close();
message.setContent(InputStream.class, bos.getInputStream());
bos.writeCacheTo(sb);
bos.close();
}
catch (IOException e)
{
throw new Fault(e);
}
}
if (!sb.toString().contains(RM_NS))
{
throw new Fault("Could not find any reference to namespace '" + RM_NS + "' in handled message.",
java.util.logging.Logger.getLogger(RMCheckInterceptor.class.getName()));
}
}
示例5: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
try
{
KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
if (message.getAttachments() != null)
for (Attachment attachment : message.getAttachments())
{
DataSource ds = attachment.getDataHandler().getDataSource();
dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
}
sign(keyStore,keyPair,keyAlias,document,dataSources);
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
示例6: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
try
{
KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
if (isSigned(document))
{
List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
if (message.getAttachments() != null)
for (Attachment attachment : message.getAttachments())
{
DataSource ds = attachment.getDataHandler().getDataSource();
dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
}
sign(keyStore,keyPair,keyAlias,document,dataSources);
}
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
示例7: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
try
{
KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
if (message.getAttachments() != null)
for (Attachment attachment : message.getAttachments())
{
DataSource ds = attachment.getDataHandler().getDataSource();
dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
}
sign(keyStore,keyPair,keyAlias,document,dataSources);
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
示例8: handleMessage
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
try
{
final LoggingMessage buffer = new LoggingMessage("Outbound Message\n---------------------------");
buffer.getHeader().append(Message.CONTENT_TYPE).append(":").append(message.get(Message.CONTENT_TYPE));
String encoding = (String)message.get(Message.ENCODING);
if (encoding != null)
buffer.getEncoding().append(encoding);
Object headers = message.get(Message.PROTOCOL_HEADERS);
if (headers != null)
buffer.getHeader().append(headers);
CachedOutputStream cos = (CachedOutputStream)message.getContent(OutputStream.class);
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
cos.writeCacheTo(buffer.getPayload(),limit);
cos.writeCacheTo(originalOs);
message.setContent(OutputStream.class,originalOs);
if (logger.isInfoEnabled())
logger.info(buffer.toString());
}
catch (IOException e)
{
new Fault(e);
}
}
示例9: onClose
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public void onClose(CachedOutputStream cos) {
try {
StringBuilder builder = new StringBuilder();
cos.writeCacheTo(builder, "utf-8");
// here comes my xml:
String postContent = builder.toString();
stringToSign = new StringBuilder(stringToSign).append("\n").append(postContent).toString();
String signature = calculateSignature(stringToSign, secret);
String authToken = generateAuth(apiKey, signature);
addHeader(message, HttpHeaders.AUTHORIZATION, authToken);
} catch (Exception e) {
}
}
示例10: logging
import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
private void logging(Message message) throws Fault {
String id = (String) message.getExchange().get(LoggingMessageSecure.ID_KEY);
if (id == null) {
id = LoggingMessageSecure.nextId();
message.getExchange().put(LoggingMessageSecure.ID_KEY, id);
}
final LoggingMessageSecure buffer = createNewLoggingMessage(id);
String encoding = (String) message.get(Message.ENCODING);
if (encoding != null) {
buffer.getEncoding().append(encoding);
}
String ct = (String) message.get(Message.CONTENT_TYPE);
if (ct != null) {
buffer.getContentType().append(ct);
}
Object headers = message.get(Message.PROTOCOL_HEADERS);
if (headers != null) {
buffer.getHeader().append(headers);
}
String uri = (String) message.get(Message.ENDPOINT_ADDRESS);
if (uri != null) {
buffer.getAddress().append(uri);
}
InputStream is = message.getContent(InputStream.class);
if (is != null) {
CachedOutputStream bos = new CachedOutputStream();
try {
IOUtils.copy(is, bos);
bos.flush();
is.close();
message.setContent(InputStream.class, bos.getInputStream());
if (bos.getTempFile() != null) {
// large thing on disk...
buffer.getMessage().append("\nMessage (saved to tmp file):\n");
buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n");
}
if (bos.size() > limit) {
buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
}
bos.writeCacheTo(buffer.getPayload(), limit);
bos.close();
} catch (IOException e) {
throw new Fault(e);
}
}
if (writer != null) {
writer.println(buffer.toString());
} else if (getLogger().isLoggable(Level.INFO)) {
getLogger().info(buffer.toString());
}
}
开发者ID:blackducksoftware,项目名称:blackduck-cxf-utilities,代码行数:60,代码来源:AbstractPayloadFilteredLoggingInInterceptor.java