src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/Invoker.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.xml.internal.ws.api.server;
27
28 import com.sun.istack.internal.NotNull;
29 import com.sun.xml.internal.ws.api.message.Packet;
30
31 import javax.xml.ws.Provider;
32 import javax.xml.ws.WebServiceContext;
33 import java.lang.reflect.InvocationTargetException;
34 import java.lang.reflect.Method;
35
36 /**
37 * Hides the detail of calling into application endpoint implementation.
38 *
39 * <p>
40 * Typical host of the JAX-WS RI would want to use
41 * {@link InstanceResolver#createDefault(Class)} and then
42 * use <tt>{@link InstanceResolver#createInvoker()} to obtain
43 * the default invoker implementation.
44 *
45 *
46 * @author Jitendra Kotamraju
47 * @author Kohsuke Kawaguchi
48 */
49 public abstract class Invoker extends com.sun.xml.internal.ws.server.sei.Invoker {
50 /**
51 * Called by {@link WSEndpoint} when it's set up.
52 *
53 * <p>
54 * This is an opportunity for {@link Invoker}
55 * to do a endpoint-specific initialization process.
56 *
57 * @param wsc
58 * The {@link WebServiceContext} instance that can be injected
59 * to the user instances.
60 * @param endpoint
61 */
62 public void start(@NotNull WSWebServiceContext wsc, @NotNull WSEndpoint endpoint) {
63 // backward compatibility
64 start(wsc);
65 }
66
67 /**
68 * @deprecated
69 * Use {@link #start(WSWebServiceContext,WSEndpoint)}
70 */
71 public void start(@NotNull WebServiceContext wsc) {
72 throw new IllegalStateException("deprecated version called");
73 }
74
75 /**
76 * Called by {@link WSEndpoint}
77 * when {@link WSEndpoint#dispose()} is called.
78 *
79 * This allows {@link InstanceResolver} to do final clean up.
80 *
81 * <p>
82 * This method is guaranteed to be only called once by {@link WSEndpoint}.
83 */
84 public void dispose() {}
85
86 /**
87 * Invokes {@link Provider#invoke(Object)}
88 */
89 public <T> T invokeProvider( @NotNull Packet p, T arg ) throws IllegalAccessException, InvocationTargetException {
90 // default slow implementation that delegates to the other invoke method.
91 return (T)invoke(p,invokeMethod,arg);
92 }
93
94 /**
95 * Invokes {@link AsyncProvider#invoke(Object, AsyncProviderCallback, WebServiceContext)}
96 */
97 public <T> void invokeAsyncProvider( @NotNull Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt ) throws IllegalAccessException, InvocationTargetException {
98 // default slow implementation that delegates to the other invoke method.
99 invoke(p, asyncInvokeMethod, arg, cbak, ctxt);
100 }
101
102 private static final Method invokeMethod;
103
104 static {
105 try {
106 invokeMethod = Provider.class.getMethod("invoke",Object.class);
107 } catch (NoSuchMethodException e) {
108 throw new AssertionError(e);
109 }
110 }
111
112 private static final Method asyncInvokeMethod;
113
114 static {
115 try {
116 asyncInvokeMethod = AsyncProvider.class.getMethod("invoke",Object.class, AsyncProviderCallback.class, WebServiceContext.class);
117 } catch (NoSuchMethodException e) {
118 throw new AssertionError(e);
119 }
120 }
121 }

mercurial