// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationService.java
// public interface ActivationService {
// 
//     /**
//      * Method called by the launcher every time the application is activate.
//      * The given arguments are the launcher argument, and so can contain
//      * the <code>-open</code> argument.
//      * @param args the arguments
//      */
//     public void activation(String[] args);
// 
//     /**
//      * Method called by the launcher when the application stops.
//      */
//     public void deactivation();
// 
// 
// }
// 
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationUtils.java
// public class ActivationUtils {
// 
//     /**
//      * Checks if the arguments contains the argument <code>arg</code>.
//      * @param args the arguments
//      * @param arg the argument to find
//      * @return <code>true</code> if the
//      */
//     public static boolean containsArgument(String[] args, String arg) {
//          if (args == null || arg == null || arg.length() == 0 || args.length == 0) {
//              return false;
//          } else {
//              for (String a : args) {
//                  if (a.equalsIgnoreCase(arg)) {
//                      return true;
//                  } else if (a.startsWith(arg + "=")) {
//                      return true;
//                  }
// 
//              }
//              return false;
//          }
//     }
// 
//     /**
//      * Gets the argument value.
//      * <ul>
//      * <li>for 'arg=value' it returns 'value'</li>
//      * <li>for 'arg value' it returns 'value'</li>
//      * @param args the arguments
//      * @param arg the argument to find
//      * @return the argument value or <code>null</code> if not found.
//      */
//     public static String getArgumentValue(String args[], String arg) {
//         if (args == null || arg == null || arg.length() == 0 || args.length == 0) {
//             return null;
//         } else {
//             for (int i = 0; i < args.length; i++) {
//                 String a = args[i];
//                 if (a.equalsIgnoreCase(arg)) {
//                     // Case 'arg value' : Look for arg + 1;
//                     if (args.length > i + 1) {
//                         return args[i+1];
//                     }
// 
//                 } else if (a.startsWith(arg + "=")) {
//                     // Case 'arg=value' : Parse the value
//                     int index = a.indexOf('=') + 1;
//                     return a.substring(index);
//                 }
//             }
// 
//             return null;
//         }
//     }
// 
//     /**
//      * Gets the value of the '-open' argument.
//      * @param args the arguments
//      * @return the value of the '-open' argument or <code>
//      * null</code> if not found.
//      */
//     public static String getOpenArgument(String args[]) {
//         return getArgumentValue(args, "-open");
//     }
// 
// 
// }


import java.util.Arrays;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import de.akquinet.chameria.services.ActivationService;
import de.akquinet.chameria.services.ActivationUtils;
/*
 * Copyright 2010 akquinet
 * 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 de.akquinet.chameria.activation.bundle;





public class ActivationServiceImpl implements ActivationService,
        BundleActivator {

    private ServiceRegistration reg;

    public int activation_count = 0;
    public String[] last_args = null;
    public String open = null;

    public void activation(String[] args) {
        System.out.println("Activation " + Arrays.asList(args));
        last_args = args;
        activation_count ++;
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationService.java
// public interface ActivationService {
// 
//     /**
//      * Method called by the launcher every time the application is activate.
//      * The given arguments are the launcher argument, and so can contain
//      * the <code>-open</code> argument.
//      * @param args the arguments
//      */
//     public void activation(String[] args);
// 
//     /**
//      * Method called by the launcher when the application stops.
//      */
//     public void deactivation();
// 
// 
// }
// 
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationUtils.java
// public class ActivationUtils {
// 
//     /**
//      * Checks if the arguments contains the argument <code>arg</code>.
//      * @param args the arguments
//      * @param arg the argument to find
//      * @return <code>true</code> if the
//      */
//     public static boolean containsArgument(String[] args, String arg) {
//          if (args == null || arg == null || arg.length() == 0 || args.length == 0) {
//              return false;
//          } else {
//              for (String a : args) {
//                  if (a.equalsIgnoreCase(arg)) {
//                      return true;
//                  } else if (a.startsWith(arg + "=")) {
//                      return true;
//                  }
// 
//              }
//              return false;
//          }
//     }
// 
//     /**
//      * Gets the argument value.
//      * <ul>
//      * <li>for 'arg=value' it returns 'value'</li>
//      * <li>for 'arg value' it returns 'value'</li>
//      * @param args the arguments
//      * @param arg the argument to find
//      * @return the argument value or <code>null</code> if not found.
//      */
//     public static String getArgumentValue(String args[], String arg) {
//         if (args == null || arg == null || arg.length() == 0 || args.length == 0) {
//             return null;
//         } else {
//             for (int i = 0; i < args.length; i++) {
//                 String a = args[i];
//                 if (a.equalsIgnoreCase(arg)) {
//                     // Case 'arg value' : Look for arg + 1;
//                     if (args.length > i + 1) {
//                         return args[i+1];
//                     }
// 
//                 } else if (a.startsWith(arg + "=")) {
//                     // Case 'arg=value' : Parse the value
//                     int index = a.indexOf('=') + 1;
//                     return a.substring(index);
//                 }
//             }
// 
//             return null;
//         }
//     }
// 
//     /**
//      * Gets the value of the '-open' argument.
//      * @param args the arguments
//      * @return the value of the '-open' argument or <code>
//      * null</code> if not found.
//      */
//     public static String getOpenArgument(String args[]) {
//         return getArgumentValue(args, "-open");
//     }
// 
// 
// }


// Path: chameria-launcher/src/test/java/de/akquinet/chameria/activation/bundle/ActivationServiceImpl.java
import java.util.Arrays;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import de.akquinet.chameria.services.ActivationService;
import de.akquinet.chameria.services.ActivationUtils;

/*
 * Copyright 2010 akquinet
 * 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 de.akquinet.chameria.activation.bundle;





public class ActivationServiceImpl implements ActivationService,
        BundleActivator {

    private ServiceRegistration reg;

    public int activation_count = 0;
    public String[] last_args = null;
    public String open = null;

    public void activation(String[] args) {
        System.out.println("Activation " + Arrays.asList(args));
        last_args = args;
        activation_count ++;
        open = ActivationUtils.getOpenArgument(args);