net\m2technologies\open_arm\samples\pojo\SimpleApplication.java

package net.m2technologies.open_arm.samples.pojo; 
 
import net.m2technologies.open_arm.OpenArmConfiguration; 
import net.m2technologies.open_arm.transport.transaction.logging.LoggingMediatorConfiguration; 
import net.m2technologies.open_arm.transport.transaction.snmp.SnmpMediatorConfiguration; 
 
import java.util.HashMap; 
import java.util.Map; 
 
/** 
 * Copyright 2004 Mark Masterson<br> <br> Licensed under the Apache License, Version 2.0 (the "License");<br> you may 
 * not use this file except in compliance with the License.<br> You may obtain a copy of the License at<br> <br> 
 * http://www.apache.org/licenses/LICENSE-2.0<br> <br> Unless required by applicable law or agreed to in writing, 
 * software<br> distributed under the License is distributed on an "AS IS" BASIS,<br> WITHOUT WARRANTIES OR CONDITIONS 
 * OF ANY KIND, either express or implied.<br> See the License for the specific language governing permissions and<br> 
 * limitations under the License.<br> 
 * <p/> 
 * <p>Description: </p> 
 * 
 * @author Mark Masterson 
 * @version 0.009 
 */ 
public class SimpleApplication extends AbstractPojoApplication { 
 
    protected SimpleApplication(final String configurationFile) { 
        super(configurationFile); 
    } 
 
    protected SimpleApplication(final OpenArmConfiguration config) { 
        super(config); 
    } 
 
    public static void main(final String[] args) { 
        // We can do this with a file name, here passed as a command line parameter... 
        //final SimpleApplication self = new SimpleApplication(args[0]); 
        // 
        // ... or, with a programmatic configuration. 
        final SimpleApplication self = new SimpleApplication(obtainOpenArmConfiguration()); 
        self.doSomething(); 
        self.doSomethingWithSetupOverhead(); 
        self.doSomethingWithExceptionHandling(); 
        System.exit(0); 
    } 
 
    private static OpenArmConfiguration obtainOpenArmConfiguration() { 
        return new OpenArmConfiguration() { 
            public Map getMediatorConfigurations() { 
                final Map result = new HashMap(); 
                result.put("net.m2technologies.open_arm.transport.transaction.snmp.SnmpMediator", 
                           new SnmpMediatorConfiguration("127.0.0.1", 
                                                         162, 
                                                         "1.3.6.1.2.1.2.0", 
                                                         "1.3.6.1.2.1.2.0.0.0.42", 
                                                         2000, 
                                                         10000, 
                                                         true)); 
                result.put("net.m2technologies.open_arm.transport.transaction.logging.LoggingMediator", 
                           new LoggingMediatorConfiguration()); 
                return result; 
            } 
        }; 
    } 
}