Skip to content

Commit

Permalink
Added a template MSDK manager
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Jul 1, 2015
1 parent b18f11c commit be57ad1
Show file tree
Hide file tree
Showing 12 changed files with 376 additions and 1 deletion.
9 changes: 8 additions & 1 deletion features/net.bioclipse.metabolomics_feature/feature.xml
Expand Up @@ -2,7 +2,7 @@
<feature
id="net.bioclipse.metabolomics_feature"
label="Metabolomics Feature"
version="2.5.0.qualifier"
version="2.6.2.qualifier"
provider-name="Bioclipse Team"
plugin="net.bioclipse.core">

Expand Down Expand Up @@ -44,4 +44,11 @@ is available at http://www.eclipse.org/legal/epl-v10.html
version="0.0.0"
unpack="false"/>

<plugin
id="net.bioclipse.msdk"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
28 changes: 28 additions & 0 deletions plugins/net.bioclipse.msdk/.project
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.bioclipse.msdk</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
18 changes: 18 additions & 0 deletions plugins/net.bioclipse.msdk/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MSDK
Bundle-SymbolicName: net.bioclipse.msdk;singleton:=true
Bundle-Version: 2.6.2.qualifier
Bundle-Activator: net.bioclipse.msdk.Activator
Bundle-Vendor: Egon Willighagen
Export-Package: net.bioclipse.msdk, net.bioclipse.msdk.business
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
net.bioclipse.core,
net.bioclipse.scripting,
org.springframework.bundle.spring.aop,
net.sf.cglib,
org.springframework.osgi.aopalliance.osgi
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.apache.log4j
Bundle-ActivationPolicy: lazy
68 changes: 68 additions & 0 deletions plugins/net.bioclipse.msdk/META-INF/spring/context.xml
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">

<osgi:service id="javaMsdkManagerOSGI"
ref="javaMsdkManager"
interface="net.bioclipse.msdk.business.IJavaMsdkManager" />

<osgi:service id="javaScriptMsdkManagerOSGI"
ref="javaScriptMsdkManager"
interface="net.bioclipse.msdk.business.IJavaScriptMsdkManager" />

<osgi:reference id="recordingAdvice"
interface="net.bioclipse.recording.IRecordingAdvice" />

<osgi:reference id="javaManagerDispatcherAdvisor"
interface="net.bioclipse.managers.business.IJavaManagerDispatcherAdvisor" />

<osgi:reference id="javaScriptManagerDispatcherAdvisor"
interface="net.bioclipse.managers.business.IJavaScriptManagerDispatcherAdvisor" />

<osgi:reference id="wrapInProxyAdvice"
interface="net.bioclipse.recording.IWrapInProxyAdvice" />

<bean id="recordingAdvisor"
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice" ref="recordingAdvice" />
<property name="pattern" value=".*" /> <!-- See also class implementation -->
</bean>

<bean id="MsdkManagerTarget"
class="net.bioclipse.msdk.business.MsdkManager">
</bean>

<bean id="javaScriptMsdkManager"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target"
ref="MsdkManagerTarget" />
<property name="proxyInterfaces"
value="net.bioclipse.msdk.business.IJavaScriptMsdkManager" />
<property name="interceptorNames" >
<list>
<value>recordingAdvisor</value>
<value>wrapInProxyAdvice</value>
<value>javaScriptManagerDispatcherAdvisor</value>
</list>
</property>
</bean>

<bean id="javaMsdkManager"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target"
ref="MsdkManagerTarget" />
<property name="proxyInterfaces"
value="net.bioclipse.msdk.business.IJavaMsdkManager" />
<property name="interceptorNames" >
<list>
<value>recordingAdvisor</value>
<value>wrapInProxyAdvice</value>
<value>javaManagerDispatcherAdvisor</value>
</list>
</property>
</bean>
</beans>
5 changes: 5 additions & 0 deletions plugins/net.bioclipse.msdk/build.properties
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.
13 changes: 13 additions & 0 deletions plugins/net.bioclipse.msdk/plugin.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

<extension
point="net.bioclipse.scripting.contribution">
<scriptContribution
service="net.bioclipse.msdk.business.MsdkManagerFactory"
id="net.bioclipse.msdk.business.MsdkManager">
</scriptContribution>
</extension>

</plugin>
105 changes: 105 additions & 0 deletions plugins/net.bioclipse.msdk/src/net/bioclipse/msdk/Activator.java
@@ -0,0 +1,105 @@
/*******************************************************************************
* Copyright (c) 2015 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: http://www.bioclipse.net/
******************************************************************************/
package net.bioclipse.msdk;

import net.bioclipse.msdk.business.IMsdkManager;
import net.bioclipse.msdk.business.IJavaMsdkManager;
import net.bioclipse.msdk.business.IJavaScriptMsdkManager;

import org.apache.log4j.Logger;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;

/**
* The Activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {

private static final Logger logger = Logger.getLogger(Activator.class);

// The shared instance
private static Activator plugin;

// Trackers for getting the managers
private ServiceTracker javaFinderTracker;
private ServiceTracker jsFinderTracker;

public Activator() {
}

public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
javaFinderTracker
= new ServiceTracker( context,
IJavaMsdkManager.class.getName(),
null );

javaFinderTracker.open();
jsFinderTracker
= new ServiceTracker( context,
IJavaScriptMsdkManager.class.getName(),
null );

jsFinderTracker.open();
}

public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}

/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}

public IMsdkManager getJavaMsdkManager() {
IMsdkManager manager = null;
try {
manager = (IMsdkManager)
javaFinderTracker.waitForService(1000*10);
}
catch (InterruptedException e) {
throw new IllegalStateException(
"Could not get the Java MsdkManager",
e );
}
if (manager == null) {
throw new IllegalStateException(
"Could not get the Java MsdkManager");
}
return manager;
}

public IJavaScriptMsdkManager getJavaScriptMsdkManager() {
IJavaScriptMsdkManager manager = null;
try {
manager = (IJavaScriptMsdkManager)
jsFinderTracker.waitForService(1000*10);
}
catch (InterruptedException e) {
throw new IllegalStateException(
"Could not get the JavaScript MsdkManager",
e );
}
if (manager == null) {
throw new IllegalStateException(
"Could not get the JavaScript MsdkManager");
}
return manager;
}
}
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright (c) 2015 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: Bioclipse Project <http://www.bioclipse.net>
******************************************************************************/
package net.bioclipse.msdk.business;

public interface IJavaMsdkManager extends IMsdkManager {

}
@@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright (c) 2015 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: Bioclipse Project <http://www.bioclipse.net>
******************************************************************************/
package net.bioclipse.msdk.business;

import net.bioclipse.managers.business.IBioclipseJSManager;

public interface IJavaScriptMsdkManager
extends IMsdkManager, IBioclipseJSManager {

}
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2015 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: http://www.bioclipse.net/
******************************************************************************/
package net.bioclipse.msdk.business;

import net.bioclipse.core.PublishedClass;
import net.bioclipse.managers.business.IBioclipseManager;

@PublishedClass(
value="TODO: Describe the manager here."
)
public interface IMsdkManager extends IBioclipseManager {

}
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2015 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: http://www.bioclipse.net/
******************************************************************************/
package net.bioclipse.msdk.business;

import net.bioclipse.managers.business.IBioclipseManager;

import org.apache.log4j.Logger;

public class MsdkManager implements IBioclipseManager {

private static final Logger logger = Logger.getLogger(MsdkManager.class);

/**
* Gives a short one word name of the manager used as variable name when
* scripting.
*/
public String getManagerName() {
return "msdk";
}
}
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2015 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: http://www.bioclipse.net/
******************************************************************************/
package net.bioclipse.msdk.business;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IExecutableExtensionFactory;

import net.bioclipse.msdk.Activator;

/**
* Factory used for giving the manager to extension points.
*
* e.g. the extension point that is used for getting manager into the scripting
* environment.
*
* @author jonalv
*/
public class MsdkManagerFactory
implements IExecutableExtension, IExecutableExtensionFactory {

private Object manager;

public void setInitializationData( IConfigurationElement config,
String propertyName,
Object data ) throws CoreException {

manager = Activator.getDefault().getJavaScriptMsdkManager();

if ( manager == null ) {
throw new IllegalStateException(
"Could not get the JavaScript flavoured " +
"MsdkManager" );
}
}

public Object create() throws CoreException {
return manager;
}
}

0 comments on commit be57ad1

Please sign in to comment.