src/share/jaxws_classes/com/sun/xml/internal/ws/model/AbstractSEIModelImpl.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
55 import javax.jws.WebParam.Mode; 55 import javax.jws.WebParam.Mode;
56 import javax.xml.bind.JAXBContext; 56 import javax.xml.bind.JAXBContext;
57 import javax.xml.bind.annotation.XmlSeeAlso; 57 import javax.xml.bind.annotation.XmlSeeAlso;
58 import javax.xml.namespace.QName; 58 import javax.xml.namespace.QName;
59 import javax.xml.ws.WebServiceException; 59 import javax.xml.ws.WebServiceException;
60 import javax.xml.ws.WebServiceFeature; 60
61
62 import com.sun.xml.internal.org.jvnet.ws.databinding.DatabindingModeFeature;
63 61
64 import java.lang.reflect.Method; 62 import java.lang.reflect.Method;
65 import java.security.AccessController; 63 import java.security.AccessController;
66 import java.security.PrivilegedActionException; 64 import java.security.PrivilegedActionException;
67 import java.security.PrivilegedExceptionAction; 65 import java.security.PrivilegedExceptionAction;
88 databindingInfo.setSEIModel(this); 86 databindingInfo.setSEIModel(this);
89 } 87 }
90 88
91 void postProcess() { 89 void postProcess() {
92 // should be called only once. 90 // should be called only once.
93 if (jaxbContext != null) 91 if (jaxbContext != null) {
94 return; 92 return;
93 }
95 populateMaps(); 94 populateMaps();
96 createJAXBContext(); 95 createJAXBContext();
97 } 96 }
98 97
99 /** 98 /**
105 for (JavaMethodImpl m : javaMethods) { 104 for (JavaMethodImpl m : javaMethods) {
106 m.freeze(port); 105 m.freeze(port);
107 putOp(m.getOperationQName(),m); 106 putOp(m.getOperationQName(),m);
108 107
109 } 108 }
110 if (databinding != null) ((com.sun.xml.internal.ws.db.DatabindingImpl)databinding).freeze(port); 109 if (databinding != null) {
110 ((com.sun.xml.internal.ws.db.DatabindingImpl)databinding).freeze(port);
111 }
111 } 112 }
112 113
113 /** 114 /**
114 * Populate methodToJM and nameToJM maps. 115 * Populate methodToJM and nameToJM maps.
115 */ 116 */
116 abstract protected void populateMaps(); 117 abstract protected void populateMaps();
117 118
119 @Override
118 public Pool.Marshaller getMarshallerPool() { 120 public Pool.Marshaller getMarshallerPool() {
119 return marshallers; 121 return marshallers;
120 } 122 }
121 123
122 /** 124 /**
123 * @return the <code>JAXBRIContext</code> 125 * @return the <code>JAXBRIContext</code>
124 * @deprecated 126 * @deprecated
125 */ 127 */
128 @Override
126 public JAXBContext getJAXBContext() { 129 public JAXBContext getJAXBContext() {
127 JAXBContext jc = bindingContext.getJAXBContext(); 130 JAXBContext jc = bindingContext.getJAXBContext();
128 if (jc != null) return jc; 131 if (jc != null) {
129 if (jaxbContext == null && jc instanceof JAXBRIContext) jaxbContext = (JAXBRIContext) bindingContext.getJAXBContext(); 132 return jc;
133 }
130 return jaxbContext; 134 return jaxbContext;
131 } 135 }
132 136
133 public BindingContext getBindingContext() { 137 public BindingContext getBindingContext() {
134 return bindingContext; 138 return bindingContext;
160 private void /*JAXBRIContext*/ createJAXBContext() { 164 private void /*JAXBRIContext*/ createJAXBContext() {
161 final List<TypeInfo> types = getAllTypeInfos(); 165 final List<TypeInfo> types = getAllTypeInfos();
162 final List<Class> cls = new ArrayList<Class>(types.size() + additionalClasses.size()); 166 final List<Class> cls = new ArrayList<Class>(types.size() + additionalClasses.size());
163 167
164 cls.addAll(additionalClasses); 168 cls.addAll(additionalClasses);
165 for (TypeInfo type : types) 169 for (TypeInfo type : types) {
166 cls.add((Class) type.type); 170 cls.add((Class) type.type);
171 }
167 172
168 try { 173 try {
169 //jaxbContext = JAXBRIContext.newInstance(cls, types, targetNamespace, false); 174 //jaxbContext = JAXBRIContext.newInstance(cls, types, targetNamespace, false);
170 // Need to avoid doPriv block once JAXB is fixed. Afterwards, use the above 175 // Need to avoid doPriv block once JAXB is fixed. Afterwards, use the above
171 bindingContext = AccessController.doPrivileged(new PrivilegedExceptionAction<BindingContext>() { 176 bindingContext = AccessController.doPrivileged(new PrivilegedExceptionAction<BindingContext>() {
172 public BindingContext run() throws Exception { 177 public BindingContext run() throws Exception {
173 if(LOGGER.isLoggable(Level.FINEST)) { 178 if(LOGGER.isLoggable(Level.FINEST)) {
174 LOGGER.log(Level.FINEST,"Creating JAXBContext with classes="+cls+" and types="+types); 179 LOGGER.log(Level.FINEST, "Creating JAXBContext with classes={0} and types={1}", new Object[]{cls, types});
175 } 180 }
176 UsesJAXBContextFeature f = features.get(UsesJAXBContextFeature.class); 181 UsesJAXBContextFeature f = features.get(UsesJAXBContextFeature.class);
177 DatabindingModeFeature dbf = features.get(DatabindingModeFeature.class); 182 com.oracle.webservices.internal.api.databinding.DatabindingModeFeature dmf =
183 features.get(com.oracle.webservices.internal.api.databinding.DatabindingModeFeature.class);
178 JAXBContextFactory factory = f!=null ? f.getFactory() : null; 184 JAXBContextFactory factory = f!=null ? f.getFactory() : null;
179 if(factory==null) factory=JAXBContextFactory.DEFAULT; 185 if(factory==null) factory=JAXBContextFactory.DEFAULT;
180 186
181 // return factory.createJAXBContext(AbstractSEIModelImpl.this,cls,types); 187 // return factory.createJAXBContext(AbstractSEIModelImpl.this,cls,types);
182 188
183 databindingInfo.properties().put(JAXBContextFactory.class.getName(), factory); 189 databindingInfo.properties().put(JAXBContextFactory.class.getName(), factory);
184 if (dbf != null) { 190 if (dmf != null) {
185 if (LOGGER.isLoggable(Level.FINE)) 191 if (LOGGER.isLoggable(Level.FINE))
186 LOGGER.fine("DatabindingModeFeature in SEI specifies mode: " 192 LOGGER.log(Level.FINE, "DatabindingModeFeature in SEI specifies mode: {0}", dmf.getMode());
187 + dbf.getMode()); 193 databindingInfo.setDatabindingMode(dmf
188 databindingInfo.setDatabindingMode(dbf
189 .getMode()); 194 .getMode());
190 } 195 }
191 196
192 if (f!=null) databindingInfo.setDatabindingMode(BindingContextFactory.DefaultDatabindingMode); 197 if (f!=null) databindingInfo.setDatabindingMode(BindingContextFactory.DefaultDatabindingMode);
193 databindingInfo.setClassLoader(classLoader); 198 databindingInfo.setClassLoader(classLoader);
194 databindingInfo.contentClasses().addAll(cls); 199 databindingInfo.contentClasses().addAll(cls);
195 databindingInfo.typeInfos().addAll(types); 200 databindingInfo.typeInfos().addAll(types);
196 databindingInfo.properties().put("c14nSupport", Boolean.FALSE); 201 databindingInfo.properties().put("c14nSupport", Boolean.FALSE);
197 databindingInfo.setDefaultNamespace(AbstractSEIModelImpl.this.getTargetNamespace()); 202 databindingInfo.setDefaultNamespace(AbstractSEIModelImpl.this.getDefaultSchemaNamespace());
198 BindingContext bc = BindingContextFactory.create(databindingInfo); 203 BindingContext bc = BindingContextFactory.create(databindingInfo);
199 if (LOGGER.isLoggable(Level.FINE)) 204 if (LOGGER.isLoggable(Level.FINE))
200 LOGGER.log(Level.FINE, 205 LOGGER.log(Level.FINE,
201 "Created binding context: " 206 "Created binding context: "
202 + bc.getClass().getName()); 207 + bc.getClass().getName());
323 if (jm != null) 328 if (jm != null)
324 javaMethods.add(jm); 329 javaMethods.add(jm);
325 } 330 }
326 331
327 /** 332 /**
328 * Applies binding related information to the RpcLitPayload. The payload map is populated correctl 333 * Applies binding related information to the RpcLitPayload. The payload map is populated correctly
329 * @return 334 * @return
330 * Returns attachment parameters if/any. 335 * Returns attachment parameters if/any.
331 */ 336 */
332 private List<ParameterImpl> applyRpcLitParamBinding(JavaMethodImpl method, WrapperParameter wrapperParameter, WSDLBoundPortType boundPortType, Mode mode) { 337 private List<ParameterImpl> applyRpcLitParamBinding(JavaMethodImpl method, WrapperParameter wrapperParameter, WSDLBoundPortType boundPortType, Mode mode) {
333 QName opName = new QName(boundPortType.getPortTypeName().getNamespaceURI(), method.getOperationName()); 338 QName opName = new QName(boundPortType.getPortTypeName().getNamespaceURI(), method.getOperationName());
441 */ 446 */
442 public String getTargetNamespace() { 447 public String getTargetNamespace() {
443 return targetNamespace; 448 return targetNamespace;
444 } 449 }
445 450
451 String getDefaultSchemaNamespace() {
452 String defaultNamespace = getTargetNamespace();
453 if (defaultSchemaNamespaceSuffix == null) return defaultNamespace;
454 if (!defaultNamespace.endsWith("/")) {
455 defaultNamespace += "/";
456 }
457 return (defaultNamespace + defaultSchemaNamespaceSuffix);
458 }
459
446 @NotNull 460 @NotNull
447 public QName getBoundPortTypeName() { 461 public QName getBoundPortTypeName() {
448 assert portName != null; 462 assert portName != null;
449 return new QName(portName.getNamespaceURI(), portName.getLocalPart()+"Binding"); 463 return new QName(portName.getNamespaceURI(), portName.getLocalPart()+"Binding");
450 } 464 }
513 protected Class contractClass; 527 protected Class contractClass;
514 protected Class endpointClass; 528 protected Class endpointClass;
515 protected ClassLoader classLoader = null; 529 protected ClassLoader classLoader = null;
516 protected WSBinding wsBinding; 530 protected WSBinding wsBinding;
517 protected BindingInfo databindingInfo; 531 protected BindingInfo databindingInfo;
532 protected String defaultSchemaNamespaceSuffix;
518 private static final Logger LOGGER = Logger.getLogger(AbstractSEIModelImpl.class.getName()); 533 private static final Logger LOGGER = Logger.getLogger(AbstractSEIModelImpl.class.getName());
519 } 534 }

mercurial