Skip to content

Instantly share code, notes, and snippets.

@cfalzone
Created July 8, 2015 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfalzone/bbc2638003a0ad5650e8 to your computer and use it in GitHub Desktop.
Save cfalzone/bbc2638003a0ad5650e8 to your computer and use it in GitHub Desktop.
package com.aquent.osgi;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import com.aquent.AquentUtil;
import com.aquent.ws.JobPostingServiceClient;
import com.aquent.ws.PostedJobs;
import com.aquent.ws.PostedJobsResponse;
import com.dotcms.repackage.org.osgi.framework.BundleContext;
import com.dotmarketing.util.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class AquentActivator extends ExtendedBundleActivator {
private static ClassPathXmlApplicationContext springContext = null;
@Override
public void start ( BundleContext ctx ) throws Exception {
// Initializing services
initializeServices(ctx);
// Get the spring Context
springContext = new ClassPathXmlApplicationContext("spring/ApplicationContext.xml");
// Test job importer
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, -1);
List<PostedJobs> results = null;
JobPostingServiceClient jobsService = (JobPostingServiceClient) springContext.getBean("JobPostingServiceClient");
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(cal.getTimeInMillis());
XMLGregorianCalendar calHours = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
PostedJobsResponse jobsResponse = jobsService.getAllPostedJobs("*****", calHours).getPostedJobs();
results = jobsResponse.getPostedJob();
Logger.info(this, "Got Jobs: "+results.size());
}
@Override
public void stop ( BundleContext ctx ) throws Exception {
// Unregister all the bundle services
unregisterServices( ctx );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment