function Engine(size) { var privateVar; function privateMethod () { //... } this.publicMethod = function () { // with access to private variables and methods }; this.engineSize = size; // public 'field' } function Car() { // generic car this.engine = new Engine(); } function BMW1800 () { this.engine = new Engine(1800); } BMW1800.prototype = new Car(); // inherit from Car var myCar = new BMW1800();
/** * Clears the chain. Sets the first and last filters to null. */ public void clear() { setFirstInboundFilter(null); setFirstOutboundFilter(null); setInboundNext(null); setLastInboundFilter(null); setLastOutboundFilter(null); setOutboundNext(null); }
/** * Returns the registered Restlet engine. * * @return The registered Restlet engine. */ public static synchronized Engine getInstance() { Engine result = instance; if (result == null) { result = register(); } return result; }
/** * Constructor. * * @param loggerName * The name of the logger to use. */ public Context(String loggerName) { this(Engine.getLogger(loggerName)); }
/** * Discovers the converter helpers and register the default helpers. * * @throws IOException */ private void discoverConverters() throws IOException { registerHelpers(DESCRIPTOR_CONVERTER_PATH, getRegisteredConverters(), null); registerDefaultConverters(); }
/** * Returns a class for a given qualified class name. * * @param className * The class name to lookup. * @return The class object. * @throws ClassNotFoundException */ protected Class<?> loadClass(String className) throws ClassNotFoundException { return Engine.loadClass(className); }
/** * Returns the helped Restlet context. * * @return The helped Restlet context. */ @Override public Context getContext() { if (Edition.CURRENT == Edition.GWT) { return null; } return super.getContext(); }
/** * Discovers the authenticator helpers and register the default helpers. * * @throws IOException */ private void discoverAuthenticators() throws IOException { registerHelpers(DESCRIPTOR_AUTHENTICATOR_PATH, getRegisteredAuthenticators(), null); registerDefaultAuthentications(); }
/** * Discovers the protocol helpers and register the default helpers. * * @throws IOException */ private void discoverProtocols() throws IOException { registerHelpers(DESCRIPTOR_PROTOCOL_PATH, getRegisteredProtocols(), null); registerDefaultProtocols(); }
/** * Sets the general log level. Modifies the global JVM's {@link LogManager}. * * @param logLevel * The general log level. */ public static void setLogLevel(Level logLevel) { Engine.logLevel = logLevel; configureLog(); }
/** * Stops the OSGi bundle by unregistering the engine with the bundle of the * Restlet API. * * @param context * The bundle context. */ public void stop(BundleContext context) throws Exception { org.restlet.engine.Engine.clear(); }
/** * Registers a new Restlet Engine. * * @return The registered engine. */ public static synchronized Engine register() { return register(true); }
public class EngineServlet extends HttpServlet { private Engine engine; // init is the "official" place for initialisation public void init(ServletConfig config) throws ServletException { super.init(config); engine = new Engine(); }
/** * Sets the Restlet log level. For loggers with a name starting with * "org.restlet". * * @param restletLogLevel * The Restlet log level. */ public static void setRestletLogLevel(Level restletLogLevel) { Engine.restletLogLevel = restletLogLevel; configureLog(); }
function Engine(){};//emtpy Engine.prototype.i = 0; var newEngine = new Engine(); console.log(newEngine.i);//0 var anotherEngine = newEngine(); newEngine.i = 1234; console.log(anotherEngine.i);//0 console.log(newEngine.i);//1234
/** * Sets the general log formatter. * * @param logFormatter * The general log formatter. */ public static void setLogFormatter(Class<? extends Formatter> logFormatter) { Engine.logFormatter = logFormatter; configureLog(); }
function Engine(){ // this is constructor. Empty since Engine do nothing. } Engine.prototype.EngineSize=null; // this is public property function Car(){ // this is Car constructor. It initializes Engine instance and stores it in Engine public property this.Engine =new Engine(); } Car.prototype.Engine =null;
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new Engine().go(); } }); }