本文整理汇总了Java中org.apache.cxf.message.Message.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getContent方法的具体用法?Java Message.getContent怎么用?Java Message.getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.message.Message
的用法示例。
在下文中一共展示了Message.getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault
{
final OutputStream os = message.getContent(OutputStream.class);
if (os == null)
{
return;
}
Logger logger = getMessageLogger(message);
if (logger.isLoggable(Level.INFO) || writer != null)
{
// Write the output while caching it for the log message
boolean hasLogged = message.containsKey(LOG_SETUP);
if (!hasLogged)
{
message.put(LOG_SETUP, Boolean.TRUE);
final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(
os);
message.setContent(OutputStream.class, newOut);
newOut.registerCallback(new LoggingCallback(logger, message, os));
}
}
}
示例2: decryptContent
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public static void decryptContent( SecurityManager securityManager, Message message, String hostIdSource,
String hostIdTarget )
{
InputStream is = message.getContent( InputStream.class );
CachedOutputStream os = new CachedOutputStream();
LOG.debug( String.format( "Decrypting IDs: %s -> %s", hostIdSource, hostIdTarget ) );
try
{
int copied = IOUtils.copyAndCloseInput( is, os );
os.flush();
byte[] data = copied > 0 ? decryptData( securityManager, hostIdSource, os.getBytes() ) : null;
org.apache.commons.io.IOUtils.closeQuietly( os );
if ( !ArrayUtils.isEmpty( data ) )
{
LOG.debug( String.format( "Decrypted payload: \"%s\"", new String( data ) ) );
message.setContent( InputStream.class, new ByteArrayInputStream( data ) );
}
else
{
LOG.debug( "Decrypted data is NULL!!!" );
}
}
catch ( Exception e )
{
LOG.error( "Error decrypting content", e );
}
}
示例3: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault
{
String messageId = (String) message.getExchange().get(
LoggingMessage.ID_KEY);
LogBean bean = new LogBean();
bean.setResponseTime(new Date());
OutputStream stream = message.getContent(OutputStream.class);
final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(
stream);
message.setContent(OutputStream.class, newOut);
newOut.registerCallback(new LoggingCallback(messageId, bean));
}
示例4: doInterfaceLog
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
private void doInterfaceLog(Message message)
{
String messageId = (String)message.getExchange().get(LoggingMessage.ID_KEY);
String currentEnvelopeMessage = "";
/*****/
OutputStream os = message.getContent(OutputStream.class);
CachedStream cs = new CachedStream();
message.setContent(OutputStream.class, cs);
message.getInterceptorChain().doIntercept(message);
try
{
cs.flush();
IOUtils.closeQuietly(cs);
CachedOutputStream csnew = (CachedOutputStream)message.getContent(OutputStream.class);
currentEnvelopeMessage = IOUtils.toString(csnew.getInputStream(), "UTF-8");
csnew.flush();
IOUtils.closeQuietly(csnew);
InputStream replaceInStream = IOUtils.toInputStream(currentEnvelopeMessage, "UTF-8");
IOUtils.copy(replaceInStream, os);
replaceInStream.close();
IOUtils.closeQuietly(replaceInStream);
os.flush();
message.setContent(OutputStream.class, os);
IOUtils.closeQuietly(os);
}
catch (IOException ioe)
{
throw new RuntimeException(ioe);
}
/*****/
InterfaceLogBean bean = new InterfaceLogBean();
bean.setTransactionId(messageId);
bean.setReq(false);
bean.setRespTime(new Date());
bean.setResultCode(getResultCode(currentEnvelopeMessage));
IInterfaceLog logger = ApplicationContextUtil.getBean("interfaceLogger");
logger.info(bean);
}
示例5: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault
{
String messageId = (String) message.getExchange().get(
LoggingMessage.ID_KEY);
LogBean bean = new LogBean();
bean.setResponseTime(new Date());
OutputStream stream = message.getContent(OutputStream.class);
final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(
stream);
message.setContent(OutputStream.class, newOut);
newOut.registerCallback(new LoggingCallback(messageId,bean));
}
示例6: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault {
Document doc = (Document)message.get(RawMessageWSDLGetInterceptor.DOCUMENT_HOLDER);
if (doc == null) {
return;
}
message.remove(RawMessageWSDLGetInterceptor.DOCUMENT_HOLDER);
OutputStream out = message.getContent(OutputStream.class);
String enc = null;
try {
enc = doc.getXmlEncoding();
} catch (Exception ex) {
//ignore - not dom level 3
}
if (enc == null) {
enc = "utf-8";
}
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out, enc);
try {
StaxUtils.writeNode(doc, writer, true);
writer.flush();
} catch (XMLStreamException e) {
throw new Fault(e);
}
}
示例7: closeInput
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
private void closeInput(Message message) {
InputStream is = message.getContent(InputStream.class);
if (is != null) {
try {
is.close();
message.removeContent(InputStream.class);
} catch (IOException ioex) {
//ignore
}
}
}
示例8: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault {
// check the fault from the message
Throwable ex = message.getContent(Throwable.class);
if (ex != null) {
if (ex instanceof Fault) {
throw (Fault)ex;
} else {
throw new Fault(ex);
}
}
List<?> params = message.getContent(List.class);
if (null != params) {
InputStream is = (InputStream)params.get(0);
OutputStream os = message.getContent(OutputStream.class);
if (os == null) {
//InOny
return;
}
try {
if (is instanceof StreamCache) {
((StreamCache)is).writeTo(os);
} else {
IOUtils.copy(is, os);
}
} catch (Exception e) {
throw new Fault(e);
} finally {
IOHelper.close(is, "input stream", null);
// Should not close the output stream as the interceptor chain will close it
}
}
}
示例9: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault {
XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
try {
// put the payload source as a document
Source source = message.getContent(Source.class);
if (source != null) {
XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(source);
StaxUtils.copy(xmlReader, xmlWriter);
}
} catch (XMLStreamException e) {
throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG, e), e);
}
}
示例10: verifyReceivedMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
private void verifyReceivedMessage(Message inMessage, String content) throws IOException {
ByteArrayInputStream bis = (ByteArrayInputStream)inMessage.getContent(InputStream.class);
byte bytes[] = new byte[bis.available()];
bis.read(bytes);
String reponse = new String(bytes);
assertEquals("The reponse date should be equals", content, reponse);
}
示例11: verifyMessageContent
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public void verifyMessageContent(Message message) {
OutputStream os = message.getContent(OutputStream.class);
assertTrue("OutputStream should not be null", os != null);
}
示例12: getXMLStreamWriter
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
protected XMLStreamWriter getXMLStreamWriter(Message message) {
return message.getContent(XMLStreamWriter.class);
}
示例13: getOAuthContext
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
protected OAuthContext getOAuthContext() {
Message m = PhaseInterceptorChain.getCurrentMessage();
OAuthContext oac = m.getContent(OAuthContext.class);
return oac;
}
示例14: handleMessage
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault {
/*
* Setup a LoggedInInfo and throw it onto the Request for use elsewhere.
* All we have is a providerNo so we access the ProviderDao directly.
* There (likely) may be a better way to do this.
*
*/
// Create a new LoggedInInfo
LoggedInInfo loggedInInfo = new LoggedInInfo();
// Obtain the OAuthContext and the login (which in OSCAR is the providerNo)
OAuthContext oc = message.getContent(OAuthContext.class);
if(oc == null) {
//not authorized yet
return;
}
String providerNo = oc.getSubject().getLogin();
// Create a new provider directly from the Dao with the providerNo.
// We can trust this number as it was authenticated from OAuth.
Provider provider = providerDao.getProvider(providerNo);
loggedInInfo.setLoggedInProvider(provider);
/* NOTE:
* A LoggedInInfo object from OAuth will NOT have the following:
* - session (no active session -- OAuth requests are stateless)
* - loggedInSecurity (the logged in user is OAuth, so no actual username/password security)
* - currentFacility (this could change, I'm not sure what it's for)
* - initiatingCode (this could change, I'm not sure what it's for)
* - locale (this could change, I'm not sure what it's for)
*/
// Throw our new loggedInInfo onto the request for future use.
HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
request.setAttribute(new LoggedInInfo().LOGGED_IN_INFO_KEY, loggedInInfo);
return;
}
示例15: getSecurityContext
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
protected SecurityContext getSecurityContext() {
Message m = PhaseInterceptorChain.getCurrentMessage();
org.apache.cxf.security.SecurityContext sc = m.getContent(org.apache.cxf.security.SecurityContext.class);
return sc;
}