Search in sources :

Example 41 with Activate

use of org.apache.felix.scr.annotations.Activate in project fabric8 by jboss-fuse.

the class MetaTypeFacade method activate.

@Activate
void activate(BundleContext bundleContext) throws Exception {
    this.bundleContext = bundleContext;
    bundleUtils = new BundleUtils(bundleContext);
    Objects.notNull(metaTypeService, "metaTypeService");
    Objects.notNull(bundleContext, "bundleContext");
    if (mbeanServer != null) {
        StandardMBean mbean = new StandardMBean(this, MetaTypeFacadeMXBean.class);
        JMXUtils.registerMBean(mbean, mbeanServer, OBJECT_NAME);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) BundleUtils(io.fabric8.utils.BundleUtils) Activate(org.apache.felix.scr.annotations.Activate)

Example 42 with Activate

use of org.apache.felix.scr.annotations.Activate in project fabric8 by jboss-fuse.

the class FabricConfigAdminBridge method activate.

@Activate
void activate(BundleContext context) {
    fabricService.get().trackConfiguration(this);
    activateComponent();
    String fileinstallDirName = context.getProperty(FELIX_FILE_INSTALL_DIR);
    if (fileinstallDirName != null) {
        File dir = new File(fileinstallDirName);
        if (dir.isDirectory() && dir.canWrite()) {
            fileinstallDir = dir;
        }
    }
    submitUpdateJob();
}
Also used : File(java.io.File) Activate(org.apache.felix.scr.annotations.Activate)

Example 43 with Activate

use of org.apache.felix.scr.annotations.Activate in project fabric8 by jboss-fuse.

the class ServiceImpl method activate.

@Activate
void activate(ComponentContext componentContext) throws IOException {
    // Use system bundle' bundle context to avoid running into
    // "Invalid BundleContext" exceptions when updating bundles
    this.bundleContext = componentContext.getBundleContext().getBundle(0).getBundleContext();
    String dir = this.bundleContext.getProperty(NEW_PATCH_LOCATION);
    if (dir != null) {
        patchDir = new File(dir);
    } else {
        dir = this.bundleContext.getProperty(PATCH_LOCATION);
        if (dir != null) {
            patchDir = new File(dir);
        } else {
            if (patchManagement.isStandaloneChild()) {
                patchDir = new File(System.getProperty("karaf.home"), "patches");
            }
            if (patchDir == null) {
                // only now fallback to datafile of system bundle
                patchDir = this.bundleContext.getDataFile("patches");
            }
        }
    }
    if (!patchDir.isDirectory()) {
        patchDir.mkdirs();
        if (!patchDir.isDirectory()) {
            throw new PatchException("Unable to create patch folder");
        }
    }
    this.karafHome = new File(bundleContext.getProperty("karaf.home"));
    this.repository = new File(bundleContext.getProperty("karaf.default.repository"));
    helper = new OSGiPatchHelper(karafHome, bundleContext);
    load(true);
    resumePendingPatchTasks();
}
Also used : PatchException(io.fabric8.patch.management.PatchException) File(java.io.File) Activate(org.apache.felix.scr.annotations.Activate)

Example 44 with Activate

use of org.apache.felix.scr.annotations.Activate in project fabric8 by jboss-fuse.

the class StandaloneBrokerDeployment method activate.

@Activate
void activate(Map<String, ?> configuration) throws Exception {
    Properties properties = toProperties(configuration);
    // Make sure the original config we are linked to still exists.
    if (!BrokerDeployment.LOAD_TS.equals(properties.getProperty("mq.fabric.server.ts"))) {
        // Our pid is now stale (or there's inactive=true property inside).
        // The properties we were activated with come from stale, not correctly deleted
        // configuration, which should be deleted in io.fabric8.mq.fabric.BrokerDeployment.deactivate()
        // we don't have to remove any real broker instance, because we've simply not created one
        Configuration ourConfig = getConfigurationAdmin().getConfiguration(properties.getProperty("service.pid"));
        // ENTESB-7515: we have to be careful to NOT delete etc/io.fabric8.mq.fabric.server-broker.cfg
        Dictionary<String, Object> props = ourConfig.getProperties();
        if (props != null && props.get("felix.fileinstall.filename") != null) {
            props.remove("felix.fileinstall.filename");
            props.put("inactive", "true");
            ourConfig.update(props);
        // we can't delete such configuration, because fileinstall will remove the file even
        // if there's no "felix.fileinstall.filename" property - that's how CM_DELETED is handled
        } else {
            ourConfig.delete();
        }
    } else {
        // Our pid is "fresh", we may procede with broker creation
        pid = properties.getProperty("service.pid");
        getBrokerDeploymentManager().updated(pid, properties);
    }
}
Also used : Configuration(org.osgi.service.cm.Configuration) Properties(java.util.Properties) Activate(org.apache.felix.scr.annotations.Activate)

Example 45 with Activate

use of org.apache.felix.scr.annotations.Activate in project fabric8 by jboss-fuse.

the class FabricPatchServiceImpl method activate.

@Activate
void activate(ComponentContext componentContext) throws IOException, BundleException {
    // Use system bundle' bundle context to avoid running into
    // "Invalid BundleContext" exceptions when updating bundles
    BundleContext bundleContext = componentContext.getBundleContext().getBundle(0).getBundleContext();
    File karafHome = new File(bundleContext.getProperty("karaf.home"));
    helper = new OSGiPatchHelper(karafHome, bundleContext);
}
Also used : File(java.io.File) BundleContext(org.osgi.framework.BundleContext) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

Activate (org.apache.felix.scr.annotations.Activate)153 ConfigurationException (org.osgi.service.cm.ConfigurationException)31 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 BundleContext (org.osgi.framework.BundleContext)19 File (java.io.File)15 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)12 URL (java.net.URL)11 Hashtable (java.util.Hashtable)11 ServiceReference (org.osgi.framework.ServiceReference)11 ServiceTrackerCustomizer (org.osgi.util.tracker.ServiceTrackerCustomizer)9 HashSet (java.util.HashSet)8 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Session (javax.jcr.Session)5 StandardMBean (javax.management.StandardMBean)5 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)5 Filter (org.osgi.framework.Filter)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4