001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.config.impl;
008    
009    import com.hammurapi.config.ConfigPackage;
010    import com.hammurapi.config.Named;
011    import com.hammurapi.config.NamedScript;
012    import com.hammurapi.config.Path;
013    import com.hammurapi.config.Profile;
014    import com.hammurapi.config.PropertySource;
015    import com.hammurapi.config.Script;
016    import com.hammurapi.config.Source;
017    
018    import com.hammurapi.config.bootstrap.ConfigurationException;
019    import com.hammurapi.config.bootstrap.Destroyable;
020    import com.hammurapi.config.bootstrap.FactoryClosure;
021    import com.hammurapi.config.bootstrap.TokenExpander.TokenSource;
022    import com.hammurapi.config.runtime.FactoryConfig;
023    import com.hammurapi.config.runtime.InjectionConfig;
024    
025    
026    import com.hammurapi.party.PartyPackage;
027    import com.hammurapi.party.Role;
028    import java.io.File;
029    
030    import java.util.Collection;
031    import java.util.logging.Logger;
032    
033    import org.codehaus.janino.ScriptEvaluator;
034    import org.eclipse.emf.common.notify.Notification;
035    import org.eclipse.emf.common.notify.NotificationChain;
036    
037    import org.eclipse.emf.common.util.EList;
038    
039    import org.eclipse.emf.ecore.EClass;
040    import org.eclipse.emf.ecore.InternalEObject;
041    
042    import org.eclipse.emf.ecore.impl.ENotificationImpl;
043    import org.eclipse.emf.ecore.impl.EObjectImpl;
044    
045    import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
046    import org.eclipse.emf.ecore.util.EObjectContainmentEList;
047    import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
048    import org.eclipse.emf.ecore.util.InternalEList;
049    
050    /**
051     * <!-- begin-user-doc -->
052     * An implementation of the model object '<em><b>Named Script</b></em>'.
053     * <!-- end-user-doc -->
054     * <p>
055     * The following features are implemented:
056     * <ul>
057     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getRoles <em>Roles</em>}</li>
058     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getDescription <em>Description</em>}</li>
059     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getConfigScript <em>Config Script</em>}</li>
060     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getId <em>Id</em>}</li>
061     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getSource <em>Source</em>}</li>
062     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#isEnabled <em>Enabled</em>}</li>
063     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getService <em>Service</em>}</li>
064     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getSupportedExecutionEnvironments <em>Supported Execution Environments</em>}</li>
065     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getHomePage <em>Home Page</em>}</li>
066     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getName <em>Name</em>}</li>
067     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#isRuntime <em>Runtime</em>}</li>
068     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getProperty <em>Property</em>}</li>
069     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getProfile <em>Profile</em>}</li>
070     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getClassPath <em>Class Path</em>}</li>
071     *   <li>{@link com.hammurapi.config.impl.NamedScriptImpl#getCode <em>Code</em>}</li>
072     * </ul>
073     * </p>
074     *
075     * @generated
076     */
077    public class NamedScriptImpl extends EObjectImpl implements NamedScript {
078            /**
079             * The cached value of the '{@link #getRoles() <em>Roles</em>}' containment reference list.
080             * <!-- begin-user-doc -->
081             * <!-- end-user-doc -->
082             * @see #getRoles()
083             * @generated
084             * @ordered
085             */
086            protected EList<Role> roles;
087            private static final Logger logger = Logger.getLogger(NamedScriptImpl.class.getName());
088            /**
089             * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
090             * <!-- begin-user-doc -->
091             * <!-- end-user-doc -->
092             * @see #getDescription()
093             * @generated
094             * @ordered
095             */
096            protected static final String DESCRIPTION_EDEFAULT = null;
097    
098            /**
099             * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
100             * <!-- begin-user-doc -->
101             * <!-- end-user-doc -->
102             * @see #getDescription()
103             * @generated
104             * @ordered
105             */
106            protected String description = DESCRIPTION_EDEFAULT;
107    
108            /**
109             * The default value of the '{@link #getConfigScript() <em>Config Script</em>}' attribute.
110             * <!-- begin-user-doc -->
111             * <!-- end-user-doc -->
112             * @see #getConfigScript()
113             * @generated
114             * @ordered
115             */
116            protected static final String CONFIG_SCRIPT_EDEFAULT = null;
117    
118            /**
119             * The cached value of the '{@link #getConfigScript() <em>Config Script</em>}' attribute.
120             * <!-- begin-user-doc -->
121             * <!-- end-user-doc -->
122             * @see #getConfigScript()
123             * @generated
124             * @ordered
125             */
126            protected String configScript = CONFIG_SCRIPT_EDEFAULT;
127    
128            /**
129             * The default value of the '{@link #getId() <em>Id</em>}' attribute.
130             * <!-- begin-user-doc -->
131             * <!-- end-user-doc -->
132             * @see #getId()
133             * @generated
134             * @ordered
135             */
136            protected static final String ID_EDEFAULT = null;
137    
138            /**
139             * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
140             * <!-- begin-user-doc -->
141             * <!-- end-user-doc -->
142             * @see #getId()
143             * @generated
144             * @ordered
145             */
146            protected String id = ID_EDEFAULT;
147    
148            /**
149             * The cached value of the '{@link #getSource() <em>Source</em>}' containment reference list.
150             * <!-- begin-user-doc -->
151             * <!-- end-user-doc -->
152             * @see #getSource()
153             * @generated
154             * @ordered
155             */
156            protected EList<Source> source;
157    
158            /**
159             * The default value of the '{@link #isEnabled() <em>Enabled</em>}' attribute.
160             * <!-- begin-user-doc -->
161             * <!-- end-user-doc -->
162             * @see #isEnabled()
163             * @generated
164             * @ordered
165             */
166            protected static final boolean ENABLED_EDEFAULT = true;
167    
168            /**
169             * The cached value of the '{@link #isEnabled() <em>Enabled</em>}' attribute.
170             * <!-- begin-user-doc -->
171             * <!-- end-user-doc -->
172             * @see #isEnabled()
173             * @generated
174             * @ordered
175             */
176            protected boolean enabled = ENABLED_EDEFAULT;
177    
178            /**
179             * The cached value of the '{@link #getService() <em>Service</em>}' attribute list.
180             * <!-- begin-user-doc -->
181             * <!-- end-user-doc -->
182             * @see #getService()
183             * @generated
184             * @ordered
185             */
186            protected EList<String> service;
187    
188            /**
189             * The cached value of the '{@link #getSupportedExecutionEnvironments() <em>Supported Execution Environments</em>}' attribute list.
190             * <!-- begin-user-doc -->
191             * <!-- end-user-doc -->
192             * @see #getSupportedExecutionEnvironments()
193             * @generated
194             * @ordered
195             */
196            protected EList<String> supportedExecutionEnvironments;
197            /**
198             * The default value of the '{@link #getHomePage() <em>Home Page</em>}' attribute.
199             * <!-- begin-user-doc -->
200             * <!-- end-user-doc -->
201             * @see #getHomePage()
202             * @generated
203             * @ordered
204             */
205            protected static final String HOME_PAGE_EDEFAULT = null;
206            /**
207             * The cached value of the '{@link #getHomePage() <em>Home Page</em>}' attribute.
208             * <!-- begin-user-doc -->
209             * <!-- end-user-doc -->
210             * @see #getHomePage()
211             * @generated
212             * @ordered
213             */
214            protected String homePage = HOME_PAGE_EDEFAULT;
215            /**
216             * The default value of the '{@link #getName() <em>Name</em>}' attribute.
217             * <!-- begin-user-doc -->
218             * <!-- end-user-doc -->
219             * @see #getName()
220             * @generated
221             * @ordered
222             */
223            protected static final String NAME_EDEFAULT = null;
224    
225            /**
226             * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
227             * <!-- begin-user-doc -->
228             * <!-- end-user-doc -->
229             * @see #getName()
230             * @generated
231             * @ordered
232             */
233            protected String name = NAME_EDEFAULT;
234    
235            /**
236             * The default value of the '{@link #isRuntime() <em>Runtime</em>}' attribute.
237             * <!-- begin-user-doc -->
238             * <!-- end-user-doc -->
239             * @see #isRuntime()
240             * @generated
241             * @ordered
242             */
243            protected static final boolean RUNTIME_EDEFAULT = true;
244    
245            /**
246             * The cached value of the '{@link #isRuntime() <em>Runtime</em>}' attribute.
247             * <!-- begin-user-doc -->
248             * <!-- end-user-doc -->
249             * @see #isRuntime()
250             * @generated
251             * @ordered
252             */
253            protected boolean runtime = RUNTIME_EDEFAULT;
254    
255            /**
256             * The cached value of the '{@link #getProperty() <em>Property</em>}' containment reference list.
257             * <!-- begin-user-doc -->
258             * <!-- end-user-doc -->
259             * @see #getProperty()
260             * @generated
261             * @ordered
262             */
263            protected EList<Named> property;
264    
265            /**
266             * The cached value of the '{@link #getProfile() <em>Profile</em>}' containment reference list.
267             * <!-- begin-user-doc -->
268             * <!-- end-user-doc -->
269             * @see #getProfile()
270             * @generated
271             * @ordered
272             */
273            protected EList<Profile> profile;
274    
275            /**
276             * The cached value of the '{@link #getClassPath() <em>Class Path</em>}' containment reference list.
277             * <!-- begin-user-doc -->
278             * <!-- end-user-doc -->
279             * @see #getClassPath()
280             * @generated
281             * @ordered
282             */
283            protected EList<Path> classPath;
284    
285            /**
286             * The default value of the '{@link #getCode() <em>Code</em>}' attribute.
287             * <!-- begin-user-doc -->
288             * <!-- end-user-doc -->
289             * @see #getCode()
290             * @generated
291             * @ordered
292             */
293            protected static final String CODE_EDEFAULT = null;
294    
295            /**
296             * The cached value of the '{@link #getCode() <em>Code</em>}' attribute.
297             * <!-- begin-user-doc -->
298             * <!-- end-user-doc -->
299             * @see #getCode()
300             * @generated
301             * @ordered
302             */
303            protected String code = CODE_EDEFAULT;
304    
305            /**
306             * <!-- begin-user-doc -->
307             * <!-- end-user-doc -->
308             * @generated
309             */
310            protected NamedScriptImpl() {
311                    super();
312            }
313    
314            /**
315             * <!-- begin-user-doc -->
316             * <!-- end-user-doc -->
317             * @generated
318             */
319            @Override
320            protected EClass eStaticClass() {
321                    return ConfigPackage.Literals.NAMED_SCRIPT;
322            }
323    
324            /**
325             * <!-- begin-user-doc -->
326             * <!-- end-user-doc -->
327             * @generated
328             */
329            public EList<Role> getRoles() {
330                    if (roles == null) {
331                            roles = new EObjectContainmentWithInverseEList<Role>(Role.class, this, ConfigPackage.NAMED_SCRIPT__ROLES, PartyPackage.ROLE__OWNER);
332                    }
333                    return roles;
334            }
335    
336            /**
337             * <!-- begin-user-doc -->
338             * <!-- end-user-doc -->
339             * @generated
340             */
341            public String getDescription() {
342                    return description;
343            }
344    
345            /**
346             * <!-- begin-user-doc -->
347             * <!-- end-user-doc -->
348             * @generated
349             */
350            public void setDescription(String newDescription) {
351                    String oldDescription = description;
352                    description = newDescription;
353                    if (eNotificationRequired())
354                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__DESCRIPTION, oldDescription, description));
355            }
356    
357            /**
358             * <!-- begin-user-doc -->
359             * <!-- end-user-doc -->
360             * @generated
361             */
362            public String getConfigScript() {
363                    return configScript;
364            }
365    
366            /**
367             * <!-- begin-user-doc -->
368             * <!-- end-user-doc -->
369             * @generated
370             */
371            public void setConfigScript(String newConfigScript) {
372                    String oldConfigScript = configScript;
373                    configScript = newConfigScript;
374                    if (eNotificationRequired())
375                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__CONFIG_SCRIPT, oldConfigScript, configScript));
376            }
377    
378            /**
379             * <!-- begin-user-doc -->
380             * <!-- end-user-doc -->
381             * @generated
382             */
383            public String getId() {
384                    return id;
385            }
386    
387            /**
388             * <!-- begin-user-doc -->
389             * <!-- end-user-doc -->
390             * @generated
391             */
392            public void setId(String newId) {
393                    String oldId = id;
394                    id = newId;
395                    if (eNotificationRequired())
396                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__ID, oldId, id));
397            }
398    
399            /**
400             * <!-- begin-user-doc -->
401             * <!-- end-user-doc -->
402             * @generated
403             */
404            public EList<Source> getSource() {
405                    if (source == null) {
406                            source = new EObjectContainmentEList<Source>(Source.class, this, ConfigPackage.NAMED_SCRIPT__SOURCE);
407                    }
408                    return source;
409            }
410    
411            /**
412             * <!-- begin-user-doc -->
413             * <!-- end-user-doc -->
414             * @generated
415             */
416            public boolean isEnabled() {
417                    return enabled;
418            }
419    
420            /**
421             * <!-- begin-user-doc -->
422             * <!-- end-user-doc -->
423             * @generated
424             */
425            public void setEnabled(boolean newEnabled) {
426                    boolean oldEnabled = enabled;
427                    enabled = newEnabled;
428                    if (eNotificationRequired())
429                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__ENABLED, oldEnabled, enabled));
430            }
431    
432            /**
433             * <!-- begin-user-doc -->
434             * <!-- end-user-doc -->
435             * @generated
436             */
437            public EList<String> getService() {
438                    if (service == null) {
439                            service = new EDataTypeUniqueEList<String>(String.class, this, ConfigPackage.NAMED_SCRIPT__SERVICE);
440                    }
441                    return service;
442            }
443    
444            /**
445             * <!-- begin-user-doc -->
446             * <!-- end-user-doc -->
447             * @generated
448             */
449            public EList<String> getSupportedExecutionEnvironments() {
450                    if (supportedExecutionEnvironments == null) {
451                            supportedExecutionEnvironments = new EDataTypeUniqueEList<String>(String.class, this, ConfigPackage.NAMED_SCRIPT__SUPPORTED_EXECUTION_ENVIRONMENTS);
452                    }
453                    return supportedExecutionEnvironments;
454            }
455    
456            /**
457             * <!-- begin-user-doc -->
458             * <!-- end-user-doc -->
459             * @generated
460             */
461            public String getHomePage() {
462                    return homePage;
463            }
464    
465            /**
466             * <!-- begin-user-doc -->
467             * <!-- end-user-doc -->
468             * @generated
469             */
470            public void setHomePage(String newHomePage) {
471                    String oldHomePage = homePage;
472                    homePage = newHomePage;
473                    if (eNotificationRequired())
474                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__HOME_PAGE, oldHomePage, homePage));
475            }
476    
477            /**
478             * <!-- begin-user-doc -->
479             * <!-- end-user-doc -->
480             * @generated
481             */
482            public String getName() {
483                    return name;
484            }
485    
486            /**
487             * <!-- begin-user-doc -->
488             * <!-- end-user-doc -->
489             * @generated
490             */
491            public void setName(String newName) {
492                    String oldName = name;
493                    name = newName;
494                    if (eNotificationRequired())
495                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__NAME, oldName, name));
496            }
497    
498            /**
499             * <!-- begin-user-doc -->
500             * <!-- end-user-doc -->
501             * @generated
502             */
503            public boolean isRuntime() {
504                    return runtime;
505            }
506    
507            /**
508             * <!-- begin-user-doc -->
509             * <!-- end-user-doc -->
510             * @generated
511             */
512            public void setRuntime(boolean newRuntime) {
513                    boolean oldRuntime = runtime;
514                    runtime = newRuntime;
515                    if (eNotificationRequired())
516                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__RUNTIME, oldRuntime, runtime));
517            }
518    
519            /**
520             * <!-- begin-user-doc -->
521             * <!-- end-user-doc -->
522             * @generated
523             */
524            public EList<Named> getProperty() {
525                    if (property == null) {
526                            property = new EObjectContainmentEList<Named>(Named.class, this, ConfigPackage.NAMED_SCRIPT__PROPERTY);
527                    }
528                    return property;
529            }
530    
531            /**
532             * <!-- begin-user-doc -->
533             * <!-- end-user-doc -->
534             * @generated
535             */
536            public EList<Profile> getProfile() {
537                    if (profile == null) {
538                            profile = new EObjectContainmentWithInverseEList<Profile>(Profile.class, this, ConfigPackage.NAMED_SCRIPT__PROFILE, ConfigPackage.PROFILE__OWNER);
539                    }
540                    return profile;
541            }
542    
543            /**
544             * <!-- begin-user-doc -->
545             * <!-- end-user-doc -->
546             * @generated
547             */
548            public EList<Path> getClassPath() {
549                    if (classPath == null) {
550                            classPath = new EObjectContainmentEList<Path>(Path.class, this, ConfigPackage.NAMED_SCRIPT__CLASS_PATH);
551                    }
552                    return classPath;
553            }
554    
555            /**
556             * <!-- begin-user-doc -->
557             * <!-- end-user-doc -->
558             * @generated
559             */
560            public String getCode() {
561                    return code;
562            }
563    
564            /**
565             * <!-- begin-user-doc -->
566             * <!-- end-user-doc -->
567             * @generated
568             */
569            public void setCode(String newCode) {
570                    String oldCode = code;
571                    code = newCode;
572                    if (eNotificationRequired())
573                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NAMED_SCRIPT__CODE, oldCode, code));
574            }
575    
576            /**
577             * <!-- begin-user-doc -->
578             * <!-- end-user-doc -->
579             * @generated NOT
580             */
581            @SuppressWarnings("unchecked")
582            public <T> T eval(Class<T> returnType, EList<String> parameterNames, EList<Class<?>> parameterTypes, EList<Object> parameters, ClassLoader classLoader) throws ConfigurationException {
583                    ScriptEvaluator se = new ScriptEvaluator();
584                    se.setReturnType(returnType);
585                    se.setParameters(parameterNames.toArray(new String[parameterNames.size()]), parameterTypes.toArray(new Class[parameterTypes.size()]));
586                    se.setParentClassLoader(classLoader);
587                    se.setThrownExceptions(new Class[] {ConfigurationException.class});
588                    try {
589                            se.cook(getConfigScript());
590                            return (T) se.evaluate(parameters.toArray());
591                    } catch (Exception e) {
592                            throw new ConfigurationException(e);
593                    }
594            }
595    
596            /**
597             * <!-- begin-user-doc -->
598             * <!-- end-user-doc -->
599             * @generated NOT
600             */
601            public FactoryClosure<Object> create(final FactoryConfig factoryConfig) throws ConfigurationException {
602                    return new FactoryClosure<Object>() {
603    
604                            public Object create(Object... args) throws ConfigurationException {
605                                    logger.fine("Creating a new named script");
606                                    ScriptEvaluator se = new ScriptEvaluator();
607                                    se.setReturnType(Object.class);
608                                    se.setParameters(new String[] {"config", "args"}, new Class[] {factoryConfig.getClass(), args.getClass()});
609                                    se.setParentClassLoader(factoryConfig.getClassLoader());
610                                    se.setThrownExceptions(new Class[] {ConfigurationException.class});
611                                    try {
612                                            se.cook(getConfigScript());
613                                            return se.evaluate(new Object[] {factoryConfig, args});
614                                    } catch (Exception e) {
615                                            throw new ConfigurationException(e);
616                                    }
617                            }
618    
619                            public Destroyable getDestroyable() throws ConfigurationException {
620                                    return null;
621                            }
622                            
623                    };
624            }
625    
626            /**
627             * <!-- begin-user-doc -->
628             * <!-- end-user-doc -->
629             * @generated
630             */
631            public void compile(EList<String> profilePath, TokenSource tokens, ClassLoader classLoader, File dir, String targetPackage, String targetClass) throws ConfigurationException {
632                    // TODO: implement this method
633                    // Ensure that you remove @generated or mark it @generated NOT
634                    throw new UnsupportedOperationException();
635            }
636    
637            /**
638             * <!-- begin-user-doc -->
639             * <!-- end-user-doc -->
640             * @generated
641             */
642            @SuppressWarnings("unchecked")
643            @Override
644            public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
645                    switch (featureID) {
646                            case ConfigPackage.NAMED_SCRIPT__ROLES:
647                                    return ((InternalEList<InternalEObject>)(InternalEList<?>)getRoles()).basicAdd(otherEnd, msgs);
648                            case ConfigPackage.NAMED_SCRIPT__PROFILE:
649                                    return ((InternalEList<InternalEObject>)(InternalEList<?>)getProfile()).basicAdd(otherEnd, msgs);
650                    }
651                    return super.eInverseAdd(otherEnd, featureID, msgs);
652            }
653    
654            /**
655             * <!-- begin-user-doc -->
656             * <!-- end-user-doc -->
657             * @generated
658             */
659            @Override
660            public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
661                    switch (featureID) {
662                            case ConfigPackage.NAMED_SCRIPT__ROLES:
663                                    return ((InternalEList<?>)getRoles()).basicRemove(otherEnd, msgs);
664                            case ConfigPackage.NAMED_SCRIPT__SOURCE:
665                                    return ((InternalEList<?>)getSource()).basicRemove(otherEnd, msgs);
666                            case ConfigPackage.NAMED_SCRIPT__PROPERTY:
667                                    return ((InternalEList<?>)getProperty()).basicRemove(otherEnd, msgs);
668                            case ConfigPackage.NAMED_SCRIPT__PROFILE:
669                                    return ((InternalEList<?>)getProfile()).basicRemove(otherEnd, msgs);
670                            case ConfigPackage.NAMED_SCRIPT__CLASS_PATH:
671                                    return ((InternalEList<?>)getClassPath()).basicRemove(otherEnd, msgs);
672                    }
673                    return super.eInverseRemove(otherEnd, featureID, msgs);
674            }
675    
676            /**
677             * <!-- begin-user-doc -->
678             * <!-- end-user-doc -->
679             * @generated
680             */
681            @Override
682            public Object eGet(int featureID, boolean resolve, boolean coreType) {
683                    switch (featureID) {
684                            case ConfigPackage.NAMED_SCRIPT__ROLES:
685                                    return getRoles();
686                            case ConfigPackage.NAMED_SCRIPT__DESCRIPTION:
687                                    return getDescription();
688                            case ConfigPackage.NAMED_SCRIPT__CONFIG_SCRIPT:
689                                    return getConfigScript();
690                            case ConfigPackage.NAMED_SCRIPT__ID:
691                                    return getId();
692                            case ConfigPackage.NAMED_SCRIPT__SOURCE:
693                                    return getSource();
694                            case ConfigPackage.NAMED_SCRIPT__ENABLED:
695                                    return isEnabled();
696                            case ConfigPackage.NAMED_SCRIPT__SERVICE:
697                                    return getService();
698                            case ConfigPackage.NAMED_SCRIPT__SUPPORTED_EXECUTION_ENVIRONMENTS:
699                                    return getSupportedExecutionEnvironments();
700                            case ConfigPackage.NAMED_SCRIPT__HOME_PAGE:
701                                    return getHomePage();
702                            case ConfigPackage.NAMED_SCRIPT__NAME:
703                                    return getName();
704                            case ConfigPackage.NAMED_SCRIPT__RUNTIME:
705                                    return isRuntime();
706                            case ConfigPackage.NAMED_SCRIPT__PROPERTY:
707                                    return getProperty();
708                            case ConfigPackage.NAMED_SCRIPT__PROFILE:
709                                    return getProfile();
710                            case ConfigPackage.NAMED_SCRIPT__CLASS_PATH:
711                                    return getClassPath();
712                            case ConfigPackage.NAMED_SCRIPT__CODE:
713                                    return getCode();
714                    }
715                    return super.eGet(featureID, resolve, coreType);
716            }
717    
718            /**
719             * <!-- begin-user-doc -->
720             * <!-- end-user-doc -->
721             * @generated
722             */
723            @SuppressWarnings("unchecked")
724            @Override
725            public void eSet(int featureID, Object newValue) {
726                    switch (featureID) {
727                            case ConfigPackage.NAMED_SCRIPT__ROLES:
728                                    getRoles().clear();
729                                    getRoles().addAll((Collection<? extends Role>)newValue);
730                                    return;
731                            case ConfigPackage.NAMED_SCRIPT__DESCRIPTION:
732                                    setDescription((String)newValue);
733                                    return;
734                            case ConfigPackage.NAMED_SCRIPT__CONFIG_SCRIPT:
735                                    setConfigScript((String)newValue);
736                                    return;
737                            case ConfigPackage.NAMED_SCRIPT__ID:
738                                    setId((String)newValue);
739                                    return;
740                            case ConfigPackage.NAMED_SCRIPT__SOURCE:
741                                    getSource().clear();
742                                    getSource().addAll((Collection<? extends Source>)newValue);
743                                    return;
744                            case ConfigPackage.NAMED_SCRIPT__ENABLED:
745                                    setEnabled((Boolean)newValue);
746                                    return;
747                            case ConfigPackage.NAMED_SCRIPT__SERVICE:
748                                    getService().clear();
749                                    getService().addAll((Collection<? extends String>)newValue);
750                                    return;
751                            case ConfigPackage.NAMED_SCRIPT__SUPPORTED_EXECUTION_ENVIRONMENTS:
752                                    getSupportedExecutionEnvironments().clear();
753                                    getSupportedExecutionEnvironments().addAll((Collection<? extends String>)newValue);
754                                    return;
755                            case ConfigPackage.NAMED_SCRIPT__HOME_PAGE:
756                                    setHomePage((String)newValue);
757                                    return;
758                            case ConfigPackage.NAMED_SCRIPT__NAME:
759                                    setName((String)newValue);
760                                    return;
761                            case ConfigPackage.NAMED_SCRIPT__RUNTIME:
762                                    setRuntime((Boolean)newValue);
763                                    return;
764                            case ConfigPackage.NAMED_SCRIPT__PROPERTY:
765                                    getProperty().clear();
766                                    getProperty().addAll((Collection<? extends Named>)newValue);
767                                    return;
768                            case ConfigPackage.NAMED_SCRIPT__PROFILE:
769                                    getProfile().clear();
770                                    getProfile().addAll((Collection<? extends Profile>)newValue);
771                                    return;
772                            case ConfigPackage.NAMED_SCRIPT__CLASS_PATH:
773                                    getClassPath().clear();
774                                    getClassPath().addAll((Collection<? extends Path>)newValue);
775                                    return;
776                            case ConfigPackage.NAMED_SCRIPT__CODE:
777                                    setCode((String)newValue);
778                                    return;
779                    }
780                    super.eSet(featureID, newValue);
781            }
782    
783            /**
784             * <!-- begin-user-doc -->
785             * <!-- end-user-doc -->
786             * @generated
787             */
788            @Override
789            public void eUnset(int featureID) {
790                    switch (featureID) {
791                            case ConfigPackage.NAMED_SCRIPT__ROLES:
792                                    getRoles().clear();
793                                    return;
794                            case ConfigPackage.NAMED_SCRIPT__DESCRIPTION:
795                                    setDescription(DESCRIPTION_EDEFAULT);
796                                    return;
797                            case ConfigPackage.NAMED_SCRIPT__CONFIG_SCRIPT:
798                                    setConfigScript(CONFIG_SCRIPT_EDEFAULT);
799                                    return;
800                            case ConfigPackage.NAMED_SCRIPT__ID:
801                                    setId(ID_EDEFAULT);
802                                    return;
803                            case ConfigPackage.NAMED_SCRIPT__SOURCE:
804                                    getSource().clear();
805                                    return;
806                            case ConfigPackage.NAMED_SCRIPT__ENABLED:
807                                    setEnabled(ENABLED_EDEFAULT);
808                                    return;
809                            case ConfigPackage.NAMED_SCRIPT__SERVICE:
810                                    getService().clear();
811                                    return;
812                            case ConfigPackage.NAMED_SCRIPT__SUPPORTED_EXECUTION_ENVIRONMENTS:
813                                    getSupportedExecutionEnvironments().clear();
814                                    return;
815                            case ConfigPackage.NAMED_SCRIPT__HOME_PAGE:
816                                    setHomePage(HOME_PAGE_EDEFAULT);
817                                    return;
818                            case ConfigPackage.NAMED_SCRIPT__NAME:
819                                    setName(NAME_EDEFAULT);
820                                    return;
821                            case ConfigPackage.NAMED_SCRIPT__RUNTIME:
822                                    setRuntime(RUNTIME_EDEFAULT);
823                                    return;
824                            case ConfigPackage.NAMED_SCRIPT__PROPERTY:
825                                    getProperty().clear();
826                                    return;
827                            case ConfigPackage.NAMED_SCRIPT__PROFILE:
828                                    getProfile().clear();
829                                    return;
830                            case ConfigPackage.NAMED_SCRIPT__CLASS_PATH:
831                                    getClassPath().clear();
832                                    return;
833                            case ConfigPackage.NAMED_SCRIPT__CODE:
834                                    setCode(CODE_EDEFAULT);
835                                    return;
836                    }
837                    super.eUnset(featureID);
838            }
839    
840            /**
841             * <!-- begin-user-doc -->
842             * <!-- end-user-doc -->
843             * @generated
844             */
845            @Override
846            public boolean eIsSet(int featureID) {
847                    switch (featureID) {
848                            case ConfigPackage.NAMED_SCRIPT__ROLES:
849                                    return roles != null && !roles.isEmpty();
850                            case ConfigPackage.NAMED_SCRIPT__DESCRIPTION:
851                                    return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
852                            case ConfigPackage.NAMED_SCRIPT__CONFIG_SCRIPT:
853                                    return CONFIG_SCRIPT_EDEFAULT == null ? configScript != null : !CONFIG_SCRIPT_EDEFAULT.equals(configScript);
854                            case ConfigPackage.NAMED_SCRIPT__ID:
855                                    return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
856                            case ConfigPackage.NAMED_SCRIPT__SOURCE:
857                                    return source != null && !source.isEmpty();
858                            case ConfigPackage.NAMED_SCRIPT__ENABLED:
859                                    return enabled != ENABLED_EDEFAULT;
860                            case ConfigPackage.NAMED_SCRIPT__SERVICE:
861                                    return service != null && !service.isEmpty();
862                            case ConfigPackage.NAMED_SCRIPT__SUPPORTED_EXECUTION_ENVIRONMENTS:
863                                    return supportedExecutionEnvironments != null && !supportedExecutionEnvironments.isEmpty();
864                            case ConfigPackage.NAMED_SCRIPT__HOME_PAGE:
865                                    return HOME_PAGE_EDEFAULT == null ? homePage != null : !HOME_PAGE_EDEFAULT.equals(homePage);
866                            case ConfigPackage.NAMED_SCRIPT__NAME:
867                                    return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
868                            case ConfigPackage.NAMED_SCRIPT__RUNTIME:
869                                    return runtime != RUNTIME_EDEFAULT;
870                            case ConfigPackage.NAMED_SCRIPT__PROPERTY:
871                                    return property != null && !property.isEmpty();
872                            case ConfigPackage.NAMED_SCRIPT__PROFILE:
873                                    return profile != null && !profile.isEmpty();
874                            case ConfigPackage.NAMED_SCRIPT__CLASS_PATH:
875                                    return classPath != null && !classPath.isEmpty();
876                            case ConfigPackage.NAMED_SCRIPT__CODE:
877                                    return CODE_EDEFAULT == null ? code != null : !CODE_EDEFAULT.equals(code);
878                    }
879                    return super.eIsSet(featureID);
880            }
881    
882            /**
883             * <!-- begin-user-doc -->
884             * <!-- end-user-doc -->
885             * @generated
886             */
887            @Override
888            public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
889                    if (baseClass == PropertySource.class) {
890                            switch (derivedFeatureID) {
891                                    case ConfigPackage.NAMED_SCRIPT__PROPERTY: return ConfigPackage.PROPERTY_SOURCE__PROPERTY;
892                                    case ConfigPackage.NAMED_SCRIPT__PROFILE: return ConfigPackage.PROPERTY_SOURCE__PROFILE;
893                                    case ConfigPackage.NAMED_SCRIPT__CLASS_PATH: return ConfigPackage.PROPERTY_SOURCE__CLASS_PATH;
894                                    default: return -1;
895                            }
896                    }
897                    if (baseClass == Script.class) {
898                            switch (derivedFeatureID) {
899                                    case ConfigPackage.NAMED_SCRIPT__CODE: return ConfigPackage.SCRIPT__CODE;
900                                    default: return -1;
901                            }
902                    }
903                    return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
904            }
905    
906            /**
907             * <!-- begin-user-doc -->
908             * <!-- end-user-doc -->
909             * @generated
910             */
911            @Override
912            public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
913                    if (baseClass == PropertySource.class) {
914                            switch (baseFeatureID) {
915                                    case ConfigPackage.PROPERTY_SOURCE__PROPERTY: return ConfigPackage.NAMED_SCRIPT__PROPERTY;
916                                    case ConfigPackage.PROPERTY_SOURCE__PROFILE: return ConfigPackage.NAMED_SCRIPT__PROFILE;
917                                    case ConfigPackage.PROPERTY_SOURCE__CLASS_PATH: return ConfigPackage.NAMED_SCRIPT__CLASS_PATH;
918                                    default: return -1;
919                            }
920                    }
921                    if (baseClass == Script.class) {
922                            switch (baseFeatureID) {
923                                    case ConfigPackage.SCRIPT__CODE: return ConfigPackage.NAMED_SCRIPT__CODE;
924                                    default: return -1;
925                            }
926                    }
927                    return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
928            }
929    
930            /**
931             * <!-- begin-user-doc -->
932             * <!-- end-user-doc -->
933             * @generated
934             */
935            @Override
936            public String toString() {
937                    if (eIsProxy()) return super.toString();
938    
939                    StringBuffer result = new StringBuffer(super.toString());
940                    result.append(" (description: ");
941                    result.append(description);
942                    result.append(", configScript: ");
943                    result.append(configScript);
944                    result.append(", id: ");
945                    result.append(id);
946                    result.append(", enabled: ");
947                    result.append(enabled);
948                    result.append(", service: ");
949                    result.append(service);
950                    result.append(", supportedExecutionEnvironments: ");
951                    result.append(supportedExecutionEnvironments);
952                    result.append(", homePage: ");
953                    result.append(homePage);
954                    result.append(", name: ");
955                    result.append(name);
956                    result.append(", runtime: ");
957                    result.append(runtime);
958                    result.append(", code: ");
959                    result.append(code);
960                    result.append(')');
961                    return result.toString();
962            }
963    
964            public void inject(InjectionConfig injectionConfig) throws ConfigurationException {
965                    logger.fine("Injecting a new named script");
966                    // Simple synchronous implementation
967                    // TODO Wrap into factory result for asynchronous injection
968                    FactoryClosure<Object> ret = create(injectionConfig);
969                    try {
970                            NamedObjectDefinitionImpl.inject(getName(), ret, injectionConfig.getTarget());
971                    } catch (Exception e) {
972                            throw new ConfigurationException(e);
973                    }
974            }
975    
976            public void injectProperties(InjectionConfig injectionConfig) throws ConfigurationException {
977                    throw new UnsupportedOperationException("This method shall not be invoked for Script and NamedScript");
978            }
979    
980    } //NamedScriptImpl