blob: b1b004bdf2b5c0b6811ed47bca9fa448ecdab4e4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* yyyymmdd bug Email and other contact information
* -------- -------- -----------------------------------------------------------
* 20060404 134913sengpl@ca.ibm.com - Seng Phung-Lu
* 20060517 142339 sengpl@ca.ibm.com - Seng Phung-Lu
*******************************************************************************/
package org.eclipse.jst.ws.internal.consumption.ui.common;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jem.java.JavaClass;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jst.j2ee.webservice.wsclient.Handler;
import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
import org.eclipse.jst.j2ee.webservice.wsclient.Webservice_clientFactory;
import org.eclipse.jst.j2ee.webservice.wsclient.internal.impl.Webservice_clientFactoryImpl;
import org.eclipse.jst.ws.internal.common.JavaMOFUtils;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem;
public class HandlerServiceRefHolder {
private String serviceRefName;
private List handlerList;
private ServiceRef serviceRef;
private IPath sourceOutputPath;
public IPath getSourceOutputPath() {
return sourceOutputPath;
}
public void setSourceOutputPath(IPath sourceOutputPath) {
this.sourceOutputPath = sourceOutputPath;
}
public IProject getProject() {
if (serviceRef!=null)
return ProjectUtilities.getProject(serviceRef);
else
return null;
}
public List getHandlerList() {
return handlerList;
}
public void setHandlerList(List handlerList) {
this.handlerList = handlerList;
}
public ServiceRef getServiceRef() {
return serviceRef;
}
public void setServiceRef(ServiceRef serviceRef) {
this.serviceRef = serviceRef;
}
public String getServiceRefName() {
return serviceRefName;
}
public void setServiceRefName(String serviceRefName) {
this.serviceRefName = serviceRefName;
}
public void addHandlerToServiceRef(){
if (handlerList!=null && !handlerList.isEmpty()){
for (int x=0;x<handlerList.size();x++){
HandlerTableItem hti = (HandlerTableItem)handlerList.get(x);
if (serviceRef!=null){
List existingHandlers = serviceRef.getHandlers();
boolean alreadyExists = false;
for (int i=0;i<existingHandlers.size();i++){
Handler handler = (Handler)existingHandlers.get(i);
if (handler.getHandlerClass().getJavaName().equals(hti.getHandlerClassName())){
alreadyExists = true;
}
}
if (!alreadyExists) {
Webservice_clientFactory wsClientFactory = new Webservice_clientFactoryImpl();
Handler newHandler = wsClientFactory.createHandler();
newHandler.setHandlerName(hti.getHandlerName());
try {
IProject project = ProjectUtilities.getProject(serviceRef);
if (project!=null) {
JavaClass javaClass = JavaMOFUtils.getJavaClass(hti.getHandlerClassName(), project);
if (javaClass != null) {
newHandler.setHandlerClass(javaClass);
}
existingHandlers.add(newHandler);
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
}
}
}
}
|