Source code: org/oasisOpen/docs/wsrf/x2005/x01/wsrfInterop20Draft03Wsdl/PrinterFactoryService.java
1 /*=============================================================================*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *=============================================================================*/
16 package org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03Wsdl;
17
18 import org.apache.ws.resource.ResourceContext;
19 import org.apache.ws.resource.ResourceUnknownException;
20 import org.apache.ws.resource.properties.faults.ResourceUnknownFaultException;
21 import org.apache.ws.resource.properties.impl.XmlBeansResourceProperty;
22 import org.apache.ws.resource.properties.v2004_11.impl.NamespaceVersionHolderImpl;
23 import org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument;
24 import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
25 import javax.naming.Context;
26 import javax.naming.InitialContext;
27
28 /**
29 * This class should be generated ONCE (and not overwritten) to maintain user-added code.
30 * If there is a change to the WSDL, then the generated implemented interfaces
31 * (representing the "base" portTypes) will change, thus showing a compile error to the
32 * user.
33 *
34 * NOTE: This class is generated. However, it will not be overwritten by subsequent
35 * calls to the code generator.
36 *
37 */
38 public class PrinterFactoryService
39 extends AbstractPrinterFactoryService
40 implements PrinterFactoryCustomOperationsPortType
41 {
42 private ResourceContext m_resourceContext;
43
44 /**
45 * Creates a new {@link PrinterFactoryService } object.
46 *
47 * @param resourceContext DOCUMENT_ME
48 */
49 public PrinterFactoryService( ResourceContext resourceContext )
50 {
51 m_resourceContext = resourceContext;
52 init( );
53 }
54
55 /**
56 * DOCUMENT_ME
57 *
58 * @return DOCUMENT_ME
59 */
60 public ResourceContext getResourceContext( )
61 {
62 return m_resourceContext;
63 }
64
65 /**
66 * DOCUMENT_ME
67 *
68 * @param requestDoc DOCUMENT_ME
69 *
70 * @return DOCUMENT_ME
71 */
72 public org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument CreatePrinter( org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterRequestDocument requestDoc )
73 {
74 CreatePrinterResponseDocument responseDocument = createResponseDocument( );
75 CreatePrinterResponseDocument.CreatePrinterResponse createPrinterResponse =
76 responseDocument.getCreatePrinterResponse( );
77 try
78 {
79
80 Context initialContext = new InitialContext( );
81 PrinterPortHome printerPortHome =
82 (PrinterPortHome) initialContext.lookup( PrinterPortHome.HOME_LOCATION );
83 PrinterPortResource instance =
84 (PrinterPortResource) printerPortHome.createPrinter( getResourceContext( ) );
85
86 //get Resource Prop for Printer Ref
87 XmlBeansResourceProperty prop =
88 (XmlBeansResourceProperty) instance.getResourcePropertySet( ).get( PrinterPortPropertyQNames.PRINTER_REFERENCE );
89
90 //set the Printer EPR on the response
91 createPrinterResponse.setPrinterReference( (EndpointReferenceType) prop.toXmlObjects( )[0] );
92 }
93 catch ( Exception e )
94 {
95 throw new ResourceUnknownFaultException( new NamespaceVersionHolderImpl( ),
96 new ResourceUnknownException( null,
97 "An error occurred when invoking CreatePrinter" ) );
98 }
99
100 return responseDocument;
101 }
102
103 /**
104 * DOCUMENT_ME
105 *
106 * @return DOCUMENT_ME
107 */
108 public org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument createResponseDocument( )
109 {
110 org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument response =
111 org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.CreatePrinterResponseDocument.Factory.newInstance( );
112 response.addNewCreatePrinterResponse( );
113 return response;
114 }
115 }