-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
JmsMeta.java
106 lines (81 loc) · 3.79 KB
/
JmsMeta.java
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
/*! ******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package org.pentaho.di.trans.step.jms;
import javax.jms.JMSContext;
import org.pentaho.di.core.ObjectLocationSpecificationMethod;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.core.injection.Injection;
import org.pentaho.di.core.injection.InjectionSupported;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.row.value.ValueMetaString;
import org.pentaho.di.core.util.GenericStepData;
import org.pentaho.di.core.util.serialization.Sensitive;
import org.pentaho.di.core.variables.VariableSpace;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.jms.context.JmsProvider;
import org.pentaho.di.trans.streaming.common.BaseStreamStepMeta;
import javax.jms.Destination;
import java.util.List;
import java.util.Objects;
import static org.pentaho.di.trans.step.jms.context.JmsProvider.ConnectionType.WEBSPHERE;
import static org.pentaho.di.trans.step.jms.context.JmsProvider.DestinationType.QUEUE;
@InjectionSupported ( localizationPrefix = "IBMMQConsumerMeta.Injection." )
public abstract class JmsMeta extends BaseStreamStepMeta {
//TODO move these props to a container pojo that can be added to both
// the consumer and producer metas, since BaseStreamStepMeta is just consumer.
@Injection ( name = "DESTINATION" ) public String destinationName = "DEV.QUEUE.1";
@Injection ( name = "URL" ) public String url = "mq://10.177.178.135:1414/QM1?channel=DEV.APP.SVRCONN";
@Injection ( name = "USERNAME" ) public String username = "devuser";
@Sensitive
@Injection ( name = "PASSWORD" ) public String password = "password";
@Injection ( name = "JNDI_URL" ) public String jndiUrl = "";
@Injection ( name = "USE_JNDI" ) public boolean useJndi = false;
@Injection ( name = "CONNECTION_TYPE" ) public String connectionType = WEBSPHERE.name();
@Injection ( name = "DESTINATION_TYPE" ) public String destinationType = QUEUE.name();
protected final List<JmsProvider> jmsProviders;
protected JmsMeta( List<JmsProvider> jmsProviders ) {
super();
this.jmsProviders = jmsProviders;
setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME );
}
@Override public RowMeta getRowMeta( String s, VariableSpace variableSpace ) throws KettleStepException {
RowMeta rowMeta = new RowMeta();
rowMeta.addValueMeta( new ValueMetaString( "message" ) );
return rowMeta;
}
@Override public StepDataInterface getStepData() {
return new GenericStepData();
}
Destination getDestination() {
return getJmsProvider().getDestination( this );
}
JMSContext getJmsContext() {
return getJmsProvider().getContext( this );
}
private JmsProvider getJmsProvider() {
return jmsProviders.stream()
.filter( prov -> prov.supports( JmsProvider.ConnectionType.valueOf( connectionType ) ) )
.filter( Objects::nonNull )
.findFirst()
.orElseThrow( () -> new RuntimeException( "FIXME" ) );
}
}