01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.js.rhino;
19:
20: import java.io.File;
21: import java.net.URLDecoder;
22:
23: import org.apache.cxf.Bus;
24: import org.apache.cxf.BusFactory;
25:
26: public class JsServiceFactoryBean {
27: private ProviderFactory providerFactory;
28: private String address;
29: private boolean isBaseAddr;
30: private String js;
31: private Bus bus;
32:
33: public JsServiceFactoryBean() {
34: providerFactory = new ProviderFactory();
35: }
36:
37: public Bus getBus() {
38: if (bus == null) {
39: bus = BusFactory.getThreadDefaultBus();
40: }
41: return bus;
42: }
43:
44: public void setBus(Bus bus) {
45: this .bus = bus;
46: }
47:
48: public void setAddress(String addr) {
49: address = addr;
50: }
51:
52: public String getAddress() {
53: return address;
54: }
55:
56: public void setIsBaseAddr(boolean isBase) {
57: isBaseAddr = isBase;
58: }
59:
60: public boolean getIsBaseAddr() {
61: return isBaseAddr;
62: }
63:
64: public void setJs(String file) {
65: js = file;
66: }
67:
68: public String getJs() {
69: return js;
70: }
71:
72: public void create() throws Exception {
73: BusFactory.setDefaultBus(bus);
74: String jsFileString = getClass().getResource(js).toURI()
75: .getPath();
76: jsFileString = URLDecoder.decode(jsFileString, "UTF-8");
77: File file = new File(jsFileString);
78: providerFactory.createAndPublish(file, address, isBaseAddr);
79: }
80:
81: }
|