/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you 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.
 */


JBI Handlers Demo 
=================

This demo shows how JAX-WS handlers can be used in a $SUBSTITUTE_NAME_UPPER$ service
engine. The demo consists of a $SUBSTITUTE_NAME_UPPER$ Service Engine and a test 
service assembly. 

The service assembly contains two service units: a service provider (server)
and a service consumer (client).

In each case the, service units are written to the standard JAX-WS 2.0 API.  
The assembly is deployed to the $SUBSTITUTE_NAME_UPPER$ Service Engine.
The Service Engine connects the service implementation (and client) to the JBI
Normalized Message Router (NMR) using a customized $SUBSTITUTE_NAME_UPPER$ transport.


Prerequisites
-------------

The demo requires Apache ServiceMix 3.1, which you can download from:

  http://incubator.apache.org/servicemix/servicemix-31.html

It assumes some familiarity with the Java Business Integration (JBI)
specification. See the following URL for details: 

  http://java.sun.com/integration/


Building the demo
-----------------

Set the SERVICEMIX_HOME environment variable.

From the samples/integration/JBI/handlers directory, build the demo by running:

   ant build



Installing and deploying
------------------------

Ensure that $SERVICEMIX_HOME/bin is in your path.

Start ServiceMix by running:

  servicemix

Install the $SUBSTITUTE_NAME_UPPER$ Service Engine:

   ant -f $SERVICEMIX_HOME/ant/servicemix-ant-task.xml install-component 
       -Dsm.install.file=./service-engine/build/lib/cxf-service-engine.jar  
       -Dsm.username=smx -Dsm.password=smx
       
   ant -f $SERVICEMIX_HOME/ant/servicemix-ant-task.xml start-component 
       -Dsm.component.name=CXFServiceEngine -Dsm.username=smx -Dsm.password=smx

Deploy the $SUBSTITUTE_NAME_UPPER$ demo service assembly

   ant -f $SERVICEMIX_HOME/ant/servicemix-ant-task.xml  deploy-service-assembly 
       -Dsm.deploy.file=./service-assembly/build/lib/cxf-service-assembly.zip  
       -Dsm.username=smx -Dsm.password=smx
       
   ant -f $SERVICEMIX_HOME/ant/servicemix-ant-task.xml start-service-assembly 
       -Dsm.service.assembly.name=cxf-demo-service-assembly -Dsm.username=smx 
       -Dsm.password=smx



What happens when the demo runs
-------------------------------

The service provider uses a SOAP protocol handler that logs incoming and 
outgoing messages to the console.  

The service provider code registers a handler using the @HandlerChain annotation
within the service implementation class. For this demo, LoggingHandler is 
a SOAPHandler that logs the entire SOAP message content to stdout. 

While the annotation in the service implementation class specifies that the 
service provider should use the LoggingHandler, the demo shows how this behavior 
is superceded by information obtained from the cxf-server.xml configuration 
file, thus allowing control over the service provider's behaviour without 
changing the code.  When the service provider uses the configuration file, 
LoggingHandler is replaced with FileLoggingHandler, which logs simple 
informative messages, not the entire message content, to the console and adds 
information to the demo.log file.

The service consumer includes a logical handler that checks the parameters on
outbound requests and short-circuits the invocation in certain circumstances. 
This handler is not specified programatically but through configuration in the 
file cxf-client.xml.  
