public String getName() public String getDescription()These methods can be added by Eclipse automatically by opening the java file and clicking on the red X on the left that indicates the error. This will give the choice to "Add unimplemented methods". When this is selected, Eclipse will add these two methods to the class. You may then fill in name and description text for these methods to return, or leave them blank.
public CbEndpointProperty[] getGetableProperties() public String getPropertyValue(int index) void setPropertyValue(int index, String value)Eclipse can automatically add these methods to the endpoint class by clicking on the red X on the left the same way as for custom code in the previous section. Select "Add unimplemented methods" and Eclipse will add the three missing methods to the class.
Next, a new Java Enumeration needs to be created in the same package as the endpoint class. This enumeration will have a constant for each endpoint property exposed in the Admin Console. Here is an example that contains three properties, a text property, an enum property and a boolean property. Use this as a template and modify it to include all of the properties for your component.
package com.bostech.corporation.component.examplecomponent;
import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.CbEndpointProperty;
public enum ExampleComponentPropertiesEnumeration {
MyProperty1 {
//This is an example Text type property
String getValue(ExampleComponentEndpoint endpoint) {
return endpoint.getMyProperty1();
}
void setValue(ExampleComponentEndpoint endpoint, Object value) {
if (isSetable()) {
String val = ((String)value).trim();
endpoint.setMyProperty1(val);
}
}
public boolean isSetable() {
return true;
}
public String getType(){
return CbEndpointProperty.TYPE_TEXT;
}
public String[] getValues() {
return null;
}
public String getName() {
return "MyProperty1";
}
},
MyProperty2 {
//This is an example Enum type property
String getValue(ExampleComponentEndpoint endpoint) {
return endpoint.getMyProperty2();
}
void setValue(ExampleComponentEndpoint endpoint, Object value) {
if (isSetable()) {
String val = ((String)value).trim();
endpoint.setMyProperty1(val);
}
}
public boolean isSetable() {
return true;
}
public String getType(){
return CbEndpointProperty.TYPE_ENUM;
}
public String[] getValues() {
return new String[]{"EnumValA","EnumValB","EnumValC"};
}
public String getName() {
return "MyProperty2";
}
},
MyProperty3 {
//This is an example Boolean type property
String getValue(ExampleComponentEndpoint endpoint) {
//Use this form if endpoint property is a String
return endpoint.getMyProperty3();
//Use this form if endpoint property is a boolean
// return (endpoint.isMyProperty3()) ? "TRUE" : "FALSE";
}
void setValue(ExampleComponentEndpoint endpoint, Object value) {
//Use this form if endpoint property is a String
if (isSetable()) {
String val = ((String)value).trim();
//Use this form if endpoint property is a String
endpoint.setMyProperty1(val);
//Use this form if endpoint property is a boolean
// endpoint.setMyProperty3("TRUE".equalsIgnoreCase(val));
}
}
public boolean isSetable() {
return true;
}
public String getType(){
return CbEndpointProperty.TYPE_BOOLEAN;
}
public String[] getValues() {
return null;
}
public String getName() {
return "MyProperty3";
}
}
;
abstract String getValue(ExampleComponentEndpoint endpoint);
abstract void setValue(ExampleComponentEndpoint endpoint, Object value);
abstract public boolean isSetable();
abstract public String getType();
abstract public String[] getValues();
abstract public String getName();
public CbEndpointProperty convertToEndpointProperty(ExampleComponentEndpoint endpoint){
CbEndpointProperty property=new CbEndpointProperty();
property.setName(getName());
property.setSetable(isSetable());
property.setType(getType());
property.setValue(getValue(endpoint));
property.setValues(getValues());
return property;
}
}
Now, you can add the logic in the three methods that were added to the endpoint class. Here is an example of the logic.
@Override
public CbEndpointProperty[] getGetableProperties() {
List<CbEndpointProperty> result = new Vector<CbEndpointProperty>();
ExampleComponentPropertiesEnumeration[] properties = ExampleComponentPropertiesEnumeration.values();
for (int i = 0; i < properties.length; i++) {
result.add(properties[i].convertToEndpointProperty(this));
}
return result.toArray(new CbEndpointProperty[] {});
}
@Override
public String getPropertyValue(int index) {
return ExampleComponentPropertiesEnumeration.values()[index].getValue(this);
}
@Override
public void setPropertyValue(int index, String value) {
ExampleComponentPropertiesEnumeration.values()[index].setValue(this,value);
}
Once these changes are made, you should be able to rebuild the custom component and use it in Chainbuilder ESB 1.4 or 2.0.
| ConvertProjectNature.JPG | ![]() |
37854 bytes |
| CustomCodeFix.JPG | ![]() |
97393 bytes |
| CustomCompFix1.JPG | ![]() |
88367 bytes |
| ExampleComponentPropertiesEnumeration.java | ![]() |
3143 bytes |