public void process () { if ( this.app.getCustomizationProfile () == null ) { this.app.setCustomizationProfile ( ProfileFactory.eINSTANCE.createProfile () ); } final Profile prof = this.app.getCustomizationProfile (); final Map<Class<?>, Exporter> countMap = new HashMap<> (); for ( final Exporter exporter : this.app.getExporter () ) { if ( exporter.getEndpoints ().size () != 1 ) { throw new IllegalStateException ( "At the moment each exporter must not have exactly than one endpoint" ); } if ( countMap.containsKey ( exporter.getClass () ) ) { throw new IllegalStateException ( String.format ( "At the moment there must not me more than one exporter at a time for the type: %s", exporter.getClass () ) ); } countMap.put ( exporter.getClass (), exporter ); final String tag = exporter.getTypeTag (); put ( prof, String.format ( "org.eclipse.scada.%s.server.exporter.ngp.exportUri", tag ), makeUri ( tag, exporter.getEndpoints ().get ( 0 ) ) ); } }
/** * Find all connections of a master server of the given type */ public static <T extends Connection> List<T> findConnections ( final EquinoxApplication app, final Class<T> clazz ) { final List<T> result = new LinkedList<> (); for ( final Connection connection : app.getConnections () ) { if ( clazz.isAssignableFrom ( connection.getClass () ) ) { result.add ( clazz.cast ( connection ) ); } } return result; }
public static Collection<Endpoint> findLocalEndpoints ( final Exporter exp ) { if ( ! ( exp.eContainer () instanceof EquinoxApplication ) ) { return Collections.emptyList (); } final EquinoxApplication app = (EquinoxApplication)exp.eContainer (); if ( ! ( app.eContainer () instanceof Node ) ) { return Collections.emptyList (); } return ( (Node)app.eContainer () ).getEndpoints (); }
public static Profile createOrGetCustomizationProfile ( final EquinoxApplication app ) { Profile profile = app.getCustomizationProfile (); if ( profile == null ) { profile = ProfileFactory.eINSTANCE.createProfile (); app.setCustomizationProfile ( profile ); } return profile; }
@Override public Driver createDriver ( final World world, final AbstractFactoryDriver driver, final Map<Node, org.eclipse.scada.configuration.world.Node> nodes ) { final T result = createDriver (); final EquinoxDriver eDriver = (EquinoxDriver)driver; final DataAccessExporter exporter = OsgiFactory.eINSTANCE.createDataAccessExporter (); exporter.setName ( "exporter" ); //$NON-NLS-1$ result.getExporter ().add ( exporter ); exporter.getEndpoints ().add ( Endpoints.registerEndpoint ( nodes.get ( driver.getNode () ), world.getOptions ().getBaseDaNgpPort () + eDriver.getInstanceNumber (), Endpoints.reference ( exporter ), "EquinoxDriver Endpoint: " + driver.getName () ) ); final ConfigurationAdministratorExporter caExporter = OsgiFactory.eINSTANCE.createConfigurationAdministratorExporter (); caExporter.setName ( "caExporter" ); //$NON-NLS-1$ result.getExporter ().add ( caExporter ); caExporter.getEndpoints ().add ( Endpoints.registerEndpoint ( nodes.get ( driver.getNode () ), world.getOptions ().getBaseCaNgpPort () + eDriver.getInstanceNumber (), Endpoints.reference ( caExporter ), "CA Exporter: " + driver.getName () ) ); Worlds.addUserService ( result, eDriver ); result.setSecurityConfiguration ( Worlds.findSecurityConfiguration ( eDriver ) ); result.getModules ().addAll ( WorldGenerator.makeModules ( world, eDriver, result ) ); configureDriver ( driver, result, nodes ); return result; }
public void process () { for ( final Exporter exporter : this.app.getExporter () ) { if ( exporter instanceof DataAccessExporter ) { processExporter ( (DataAccessExporter)exporter ); } } }
public static Profile makeProfile ( final EquinoxApplication app ) { final Profile profile = flatten ( EcoreUtil.copy ( app.getProfile () ) ); if ( profile == null ) { throw new IllegalStateException ( "Application implemenation did not return a profile" ); } if ( app.getCustomizationProfile () != null ) { mergeIntoProfile ( flatten ( EcoreUtil.copy ( app.getCustomizationProfile () ) ), profile ); } profile.setName ( String.format ( "Custom profile for %s on node %s", app.getName (), Nodes.fromApp ( app ).getHostName () ) ); profile.setDescription ( null ); // finally clear null system properties clearNulls ( profile ); return profile; }
private Endpoint createExporter ( final EClass exporterClass, final Node node, final EquinoxApplication application, final int port ) { final Exporter exporter = (Exporter)EcoreUtil.create ( exporterClass ); final Endpoint ep = Endpoints.registerEndpoint ( node, port, Endpoints.reference ( exporter ), String.format ( "Exporter Endpoint: %s - %s", exporter.getTypeTag (), exporter.getName () ) ); node.getEndpoints ().add ( ep ); exporter.setName ( application.getName () + "/exporter" ); exporter.getEndpoints ().add ( ep ); application.getExporter ().add ( exporter ); return ep; }
private void processProfile ( final File output ) throws IOException { final Profile profile = makeProfile ( this.app ); final File profileFile = new File ( output, this.app.getName () + ".profile.xml" ); //$NON-NLS-1$ final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( profileFile.toString () ) ); r.getContents ().add ( EcoreUtil.copy ( profile ) ); final Map<Object, Object> options = new HashMap<> (); options.put ( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ r.save ( options ); }
@Override public void process ( final OscarContext ctx, final EquinoxApplication application, final IProgressMonitor monitor ) throws Exception { new TypeWalker<> ( this.clazz ).walk ( application.getModules (), new TypeVisitor<T> () { @Override public void visit ( final T item ) throws Exception { process ( item, application, ctx, monitor ); } } ); }
public void process ( final IProgressMonitor monitor ) { addSecurityRules ( this.app.getSecurityConfiguration (), monitor ); }
@SuppressWarnings ( "unchecked" ) @Override public Driver process ( final org.eclipse.scada.configuration.infrastructure.Driver infraDriver, final Map<Node, org.eclipse.scada.configuration.world.Node> nodes ) { final T driver = (T)infraDriver; final S result = createDriver ( driver, nodes ); result.setName ( driver.getName () ); result.setSecurityConfiguration ( Worlds.findSecurityConfiguration ( driver ) ); Worlds.addUserService ( result, driver ); final World world = Containers.findContainer ( infraDriver, World.class ); final DataAccessExporter exporter = OsgiFactory.eINSTANCE.createDataAccessExporter (); exporter.setName ( "exporter" ); //$NON-NLS-1$ result.getExporter ().add ( exporter ); exporter.getEndpoints ().add ( Endpoints.registerEndpoint ( nodes.get ( driver.getNode () ), world.getOptions ().getBaseDaNgpPort () + driver.getInstanceNumber (), Endpoints.reference ( exporter ), "EquinoxDriver Endpoint: " + driver.getName () ) ); final ConfigurationAdministratorExporter caExporter = OsgiFactory.eINSTANCE.createConfigurationAdministratorExporter (); caExporter.setName ( "caExporter" ); //$NON-NLS-1$ result.getExporter ().add ( caExporter ); caExporter.getEndpoints ().add ( Endpoints.registerEndpoint ( nodes.get ( driver.getNode () ), world.getOptions ().getBaseCaNgpPort () + driver.getInstanceNumber (), Endpoints.reference ( caExporter ), "CA Exporter: " + driver.getName () ) ); result.getModules ().addAll ( WorldGenerator.makeModules ( world, driver, result ) ); return result; }
public void process () { for ( final Exporter exporter : this.app.getExporter () ) { if ( exporter instanceof DataAccessExporter ) { processExporter ( (DataAccessExporter)exporter ); } } }
public static Profile makeProfile ( final EquinoxApplication app ) { final Profile profile = flatten ( EcoreUtil.copy ( app.getProfile () ) ); if ( profile == null ) { throw new IllegalStateException ( "Application implemenation did not return a profile" ); } if ( app.getCustomizationProfile () != null ) { mergeIntoProfile ( flatten ( EcoreUtil.copy ( app.getCustomizationProfile () ) ), profile ); } profile.setName ( String.format ( "Custom profile for %s on node %s", app.getName (), Nodes.fromApp ( app ).getHostName () ) ); profile.setDescription ( null ); // finally clear null system properties clearNulls ( profile ); return profile; }
public static Profile createOrGetCustomizationProfile ( final EquinoxApplication app ) { Profile profile = app.getCustomizationProfile (); if ( profile == null ) { profile = ProfileFactory.eINSTANCE.createProfile (); app.setCustomizationProfile ( profile ); } return profile; }
private void processProfile ( final File output ) throws IOException { final Profile profile = makeProfile ( this.app ); final File profileFile = new File ( output, this.app.getName () + ".profile.xml" ); //$NON-NLS-1$ final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( profileFile.toString () ) ); r.getContents ().add ( EcoreUtil.copy ( profile ) ); final Map<Object, Object> options = new HashMap<> (); options.put ( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ r.save ( options ); }
@Override public void process ( final OscarContext ctx, final EquinoxApplication application, final IProgressMonitor monitor ) throws Exception { new TypeWalker<> ( this.clazz ).walk ( application.getModules (), new TypeVisitor<T> () { @Override public void visit ( final T item ) throws Exception { process ( item, application, ctx, monitor ); } } ); }
public void process ( final IProgressMonitor monitor ) { addSecurityRules ( this.app.getSecurityConfiguration (), monitor ); }
public void process () { if ( this.app.getCustomizationProfile () == null ) { this.app.setCustomizationProfile ( ProfileFactory.eINSTANCE.createProfile () ); } final Profile prof = this.app.getCustomizationProfile (); final Map<Class<?>, Exporter> countMap = new HashMap<> (); for ( final Exporter exporter : this.app.getExporter () ) { if ( exporter.getEndpoints ().size () != 1 ) { throw new IllegalStateException ( "At the moment each exporter must not have exactly than one endpoint" ); } if ( countMap.containsKey ( exporter.getClass () ) ) { throw new IllegalStateException ( String.format ( "At the moment there must not me more than one exporter at a time for the type: %s", exporter.getClass () ) ); } countMap.put ( exporter.getClass (), exporter ); final String tag = exporter.getTypeTag (); put ( prof, String.format ( "org.eclipse.scada.%s.server.exporter.ngp.exportUri", tag ), makeUri ( tag, exporter.getEndpoints ().get ( 0 ) ) ); } }
protected Collection<Endpoint> getEndpoints ( final EquinoxApplication app ) { final Collection<Endpoint> result = new LinkedList<> (); if ( app == null ) { return result; } for ( final Exporter exporter : app.getExporter () ) { result.addAll ( exporter.getEndpoints () ); } return result; }