/*=============================================================================*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.
*=============================================================================*/
package org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03Wsdl;
import org.apache.ws.resource.ResourceContext;
import org.apache.ws.resource.ResourceUnknownException;
import org.apache.ws.resource.properties.faults.ResourceUnknownFaultException;
import org.apache.ws.resource.properties.impl.XmlBeansResourceProperty;
import org.apache.ws.resource.properties.v2004_11.impl.NamespaceVersionHolderImpl;
import org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument;
import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* This class should be generated ONCE (and not overwritten) to maintain user-added code.
* If there is a change to the WSDL, then the generated implemented interfaces
* (representing the "base" portTypes) will change, thus showing a compile error to the
* user.
*
* NOTE: This class is generated. However, it will not be overwritten by subsequent
* calls to the code generator.
*
*/
public class PrinterFactoryService
extends AbstractPrinterFactoryService
implements PrinterFactoryCustomOperationsPortType
{
private ResourceContext m_resourceContext;
/**
* Creates a new {@link PrinterFactoryService } object.
*
* @param resourceContext DOCUMENT_ME
*/
public PrinterFactoryService( ResourceContext resourceContext )
{
m_resourceContext = resourceContext;
init( );
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public ResourceContext getResourceContext( )
{
return m_resourceContext;
}
/**
* DOCUMENT_ME
*
* @param requestDoc DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument CreatePrinter( org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterRequestDocument requestDoc )
{
CreatePrinterResponseDocument responseDocument = createResponseDocument( );
CreatePrinterResponseDocument.CreatePrinterResponse createPrinterResponse =
responseDocument.getCreatePrinterResponse( );
try
{
Context initialContext = new InitialContext( );
PrinterPortHome printerPortHome =
(PrinterPortHome) initialContext.lookup( PrinterPortHome.HOME_LOCATION );
PrinterPortResource instance =
(PrinterPortResource) printerPortHome.createPrinter( getResourceContext( ) );
//get Resource Prop for Printer Ref
XmlBeansResourceProperty prop =
(XmlBeansResourceProperty) instance.getResourcePropertySet( ).get( PrinterPortPropertyQNames.PRINTER_REFERENCE );
//set the Printer EPR on the response
createPrinterResponse.setPrinterReference( (EndpointReferenceType) prop.toXmlObjects( )[0] );
}
catch ( Exception e )
{
throw new ResourceUnknownFaultException( new NamespaceVersionHolderImpl( ),
new ResourceUnknownException( null,
"An error occurred when invoking CreatePrinter" ) );
}
return responseDocument;
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument createResponseDocument( )
{
org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument response =
org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument.Factory.newInstance( );
response.addNewCreatePrinterResponse( );
return response;
}
}